DecodePartial

Trait DecodePartial 

Source
pub trait DecodePartial<S: ErrorSpan>: Sized {
    // Required methods
    fn insert_child(
        &mut self,
        node: &SpannedNode<S>,
        ctx: &mut Context<S>,
    ) -> Result<bool, DecodeError<S>>;
    fn insert_property(
        &mut self,
        name: &Spanned<Box<str>, S>,
        value: &Value<S>,
        ctx: &mut Context<S>,
    ) -> Result<bool, DecodeError<S>>;
}
Expand description

The trait is implemented for structures that can be used as part of other structs

The type of field that #[knuffel(flatten)] is used for should implement this trait. It is automatically implemented by #[derive(knuffel::Decode)] by structures that have only optional properties and children (no arguments).

Required Methods§

Source

fn insert_child( &mut self, node: &SpannedNode<S>, ctx: &mut Context<S>, ) -> Result<bool, DecodeError<S>>

The method is called when unknown child is encountered by parent structure

Returns Ok(true) if the child is “consumed” (i.e. stored in this structure).

Source

fn insert_property( &mut self, name: &Spanned<Box<str>, S>, value: &Value<S>, ctx: &mut Context<S>, ) -> Result<bool, DecodeError<S>>

The method is called when unknown property is encountered by parent structure

Returns Ok(true) if the property is “consumed” (i.e. stored in this structure).

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<S: ErrorSpan, T: DecodePartial<S>> DecodePartial<S> for Box<T>

Source§

fn insert_child( &mut self, node: &SpannedNode<S>, ctx: &mut Context<S>, ) -> Result<bool, DecodeError<S>>

Source§

fn insert_property( &mut self, name: &Spanned<Box<str>, S>, value: &Value<S>, ctx: &mut Context<S>, ) -> Result<bool, DecodeError<S>>

Source§

impl<S: ErrorSpan, T: DecodePartial<S>> DecodePartial<S> for Rc<T>

Source§

fn insert_child( &mut self, node: &SpannedNode<S>, ctx: &mut Context<S>, ) -> Result<bool, DecodeError<S>>

Source§

fn insert_property( &mut self, name: &Spanned<Box<str>, S>, value: &Value<S>, ctx: &mut Context<S>, ) -> Result<bool, DecodeError<S>>

Source§

impl<S: ErrorSpan, T: DecodePartial<S>> DecodePartial<S> for Arc<T>

Source§

fn insert_child( &mut self, node: &SpannedNode<S>, ctx: &mut Context<S>, ) -> Result<bool, DecodeError<S>>

Source§

fn insert_property( &mut self, name: &Spanned<Box<str>, S>, value: &Value<S>, ctx: &mut Context<S>, ) -> Result<bool, DecodeError<S>>

Implementors§