hyperactor_mesh/
reference.rs

1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree.
7 */
8
9use std::cmp::Ord;
10use std::cmp::PartialOrd;
11use std::fmt;
12use std::hash::Hash;
13use std::str::FromStr;
14
15use hyperactor_config::AttrValue;
16use serde::Deserialize;
17use serde::Serialize;
18use typeuri::Named;
19
20use crate::Name;
21
22#[derive(
23    Debug,
24    Serialize,
25    Deserialize,
26    Clone,
27    PartialEq,
28    Eq,
29    PartialOrd,
30    Hash,
31    Ord,
32    Named
33)]
34pub struct ProcMeshId(pub String);
35
36/// Actor Mesh ID.
37#[derive(
38    Debug,
39    Serialize,
40    Deserialize,
41    Clone,
42    PartialEq,
43    Eq,
44    PartialOrd,
45    Hash,
46    Ord,
47    Named,
48    AttrValue
49)]
50pub struct ActorMeshId(pub Name);
51
52impl fmt::Display for ActorMeshId {
53    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54        write!(f, "{}", self.0)
55    }
56}
57
58impl FromStr for ActorMeshId {
59    type Err = anyhow::Error;
60
61    fn from_str(s: &str) -> Result<Self, Self::Err> {
62        Ok(ActorMeshId(Name::from_str(s)?))
63    }
64}