Trait AttrValue

Source
pub trait AttrValue:
    Named
    + Sized
    + Serialize
    + DeserializeOwned
    + Send
    + Sync
    + Clone
    + 'static {
    // Required methods
    fn display(&self) -> String;
    fn parse(value: &str) -> Result<Self, Error>;
}
Expand description

This trait must be implemented by all attribute values. In addition to enforcing the supertrait Named + Sized + Serialize + DeserializeOwned + Send + Sync + Clone, AttrValue requires that the type be representable in “display” format.

AttrValue includes its own display and parse so that behavior can be tailored for attribute purposes specifically, allowing common types like Duration to be used without modification.

This crate includes a derive macro for AttrValue, which uses the type’s std::string::ToString for display, and std::str::FromStr for parsing.

Required Methods§

Source

fn display(&self) -> String

Display the value, typically using std::fmt::Display. This is called to show the output in human-readable form.

Source

fn parse(value: &str) -> Result<Self, Error>

Parse a value from a string, typically using std::str::FromStr.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl AttrValue for IpAddr

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for bool

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for f32

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for f64

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for i8

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for i16

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for i32

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for i64

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for i128

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for isize

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for u8

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for u16

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for u32

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for u64

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for u128

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for usize

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for Shape

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for Point

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for String

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for Ipv4Addr

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for Ipv6Addr

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for Duration

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Source§

impl AttrValue for SystemTime

Source§

fn display(&self) -> String

Source§

fn parse(value: &str) -> Result<Self, Error>

Implementors§