StructInstance

Trait StructInstance 

Source
pub trait StructInstance<'s>: Instance<'s> {
    // Required methods
    fn get_value<'a>(&'a self, field: &str) -> Option<CowValue<'a, 's>>
       where 's: 'a;
    fn update<'a>(
        &'a mut self,
        update: &'a (dyn StructInstance<'s> + 's),
        field_mask: Option<&FieldMask>,
        replace_repeated: bool,
    ) -> Result<(), Error>;
    fn values<'a>(&'a self) -> HashMap<SmolStr, CowValue<'a, 's>>;
    fn boxed_clone(&self) -> Box<dyn StructInstance<'s> + 's>;
    fn into_boxed_instance(self: Box<Self>) -> Box<dyn Instance<'s> + 's>;
}
Expand description

A reflected struct

Required Methods§

Source

fn get_value<'a>(&'a self, field: &str) -> Option<CowValue<'a, 's>>
where 's: 'a,

Returns a reference to a field in a struct

Source

fn update<'a>( &'a mut self, update: &'a (dyn StructInstance<'s> + 's), field_mask: Option<&FieldMask>, replace_repeated: bool, ) -> Result<(), Error>

Updates an instance based on the instance passed in. If a field mask is specified only the fields passed with the mask will be updated.

Source

fn values<'a>(&'a self) -> HashMap<SmolStr, CowValue<'a, 's>>

Returns a HashMap containing all the attributes of the instance.

Source

fn boxed_clone(&self) -> Box<dyn StructInstance<'s> + 's>

Returns a clone of the instance in a Box.

Source

fn into_boxed_instance(self: Box<Self>) -> Box<dyn Instance<'s> + 's>

Casts Self to a Box<dyn Instance>

Trait Implementations§

Source§

impl<'s> Clone for Box<dyn StructInstance<'s> + 's>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'s> Debug for dyn StructInstance<'s> + 's

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'s> PartialEq for dyn StructInstance<'s> + 's

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'ty> Typed<'ty> for Box<dyn StructInstance<'ty> + 'ty>

Source§

fn ty() -> ValueTy

Source§

fn as_value<'val>(&'val self) -> Value<'val, 'ty>
where 'ty: 'val,

Implementors§