TypedProperty

Trait TypedProperty 

Source
pub trait TypedProperty {
    // Required method
    fn from_value(value: &PropertyValue) -> ConversionResult<Self>
       where Self: Sized;
}
Expand description

Represents a type which can be created from a PropertyValue

TypedProperty can be implemented for user-defined types to make it more convenient to parse things. However, if you want to implement it for types that aren’t defined in your crate, you’ll have to use a newtype.

Example:

use ccs2::{CommaSeparatedList, ToType};
let context = ccs2::Context::from_str_without_tracing("items = '1, 2, 3, 4'").unwrap();

let items = context.get_type::<CommaSeparatedList>("items")?;

assert_eq!(items.0, vec!["1", "2", "3", "4"]);

Note: The combined error type of the “get and convert” chain is ContextError.

Required Methods§

Source

fn from_value(value: &PropertyValue) -> ConversionResult<Self>
where Self: Sized,

Implementations on Foreign Types§

Source§

impl TypedProperty for bool

Source§

impl TypedProperty for f32

Source§

impl TypedProperty for f64

Source§

impl TypedProperty for i8

Source§

impl TypedProperty for i16

Source§

impl TypedProperty for i32

Source§

impl TypedProperty for i64

Source§

impl TypedProperty for u8

Source§

impl TypedProperty for u16

Source§

impl TypedProperty for u32

Source§

impl TypedProperty for u64

Source§

impl TypedProperty for DateTime<FixedOffset>

Source§

impl TypedProperty for String

Source§

impl TypedProperty for Duration

Requires the extra_conversions feature, as it uses the humantime crate to do the parsing

Source§

impl TypedProperty for PathBuf

Source§

impl TypedProperty for SystemTime

Requires the extra_conversions feature, as it uses the chrono crate to do the parsing

See chrono::DateTime::parse_from_rfc3339 for supported formatting

Implementors§