Trait Builder

Source
pub trait Builder<'buffer> {
    type Output;

    // Required methods
    fn entry<Context>(
        &mut self,
        key: &'buffer str,
        decoder: &mut Decoder<'buffer>,
        context: &mut Context,
    ) -> Result<bool, Error>;
    fn build(self) -> Result<Self::Output, Error>;
}
Expand description

A builder that can hold the intermediate state while an object is being decoded from a map.

Required Associated Types§

Source

type Output

The type of object that the builder produces on success.

Required Methods§

Source

fn entry<Context>( &mut self, key: &'buffer str, decoder: &mut Decoder<'buffer>, context: &mut Context, ) -> Result<bool, Error>

Accepts a single map entry.

The key parameter is the string key. The decoder parameter is positioned at the corresponding value.

If this builder (or a subordinate builder for a nested object) understands the key, it should consume the corresponding value and return true. If not, it should return false without consuming the corresponding value. This allows delegation to subordinate builders to work, as only exactly one builder in the tree will directly return true (as opposed to doing so via delegation), and only that one builder will consume the value.

§Errors

This fails if the value is not acceptable, for example if it is of the wrong data type.

Source

fn build(self) -> Result<Self::Output, Error>

Finishes building the object.

§Errors

This fails if the object is not buildable, for example if a required value is missing.

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.

Implementors§

Source§

impl<'buffer> Builder<'buffer> for OptionFluidBuilder<'buffer>

Source§

type Output = OptionFluid<'buffer>

Source§

impl<'buffer> Builder<'buffer> for TankBuilder<'buffer>

Source§

type Output = Tank<'buffer>

Source§

impl<'buffer> Builder<'buffer> for OptionItemStackBuilder<'buffer>