#[derive(AttrValue)]
Expand description
Derive the [hyperactor::attrs::AttrValue
] trait for a struct or enum.
This macro generates an implementation that uses the type’s ToString
and FromStr
implementations for the display
and parse
methods respectively.
The type must already implement the required super-traits:
Named + Sized + Serialize + DeserializeOwned + Send + Sync + Clone + 'static
as well as ToString
and FromStr
.
§Example
#[derive(AttrValue, Named, Serialize, Deserialize, Clone)]
struct MyCustomType {
value: String,
}
impl std::fmt::Display for MyCustomType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.value)
}
}
impl std::str::FromStr for MyCustomType {
type Err = std::io::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(MyCustomType {
value: s.to_string(),
})
}
}