Skip to main content

MessageField

Trait MessageField 

Source
pub trait MessageField: Sized {
    // Required methods
    fn to_value(self) -> Value;
    fn from_value(v: &Value) -> Option<Self>;
}
Expand description

A type a message field can hold: to a Value and back. Implemented for the numbers, bool, String, Value itself, Option (absent or null is None) and Vec; #[derive(Message)] implements it for the type it derives, so one message can carry another.

Required Methods§

Source

fn to_value(self) -> Value

Source

fn from_value(v: &Value) -> Option<Self>

None for a value of the wrong shape.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl MessageField for String

Source§

impl MessageField for bool

Source§

impl MessageField for f32

Source§

impl MessageField for f64

Source§

impl MessageField for i8

Source§

impl MessageField for i16

Source§

impl MessageField for i32

Source§

impl MessageField for i64

Source§

impl MessageField for isize

Source§

impl MessageField for u8

Source§

impl MessageField for u16

Source§

impl MessageField for u32

Source§

impl MessageField for u64

Source§

impl MessageField for usize

Source§

impl<T: MessageField> MessageField for Box<T>

Source§

impl<T: MessageField> MessageField for Option<T>

Source§

impl<T: MessageField> MessageField for Vec<T>

Implementors§