Struct sequent::Decoder

source ·
pub struct Decoder<S> { /* private fields */ }
Expand description

Decodes a name-value tuple into an Event object using a preconfigured map of parsers.

Implementations§

Creates a new decoder from the given vector of parsers.

Panics

If there was an error building a Decoder from the given parsers.

An iterator over the underlying parsers.

Decodes a given encoded representation for an event of a given name into a Event object.

Errors

ParseEventError if an event could not be decoded from the given name and encoded pair.

Examples found in repository?
src/persistence.rs (line 62)
59
60
61
62
63
64
65
66
67
68
69
70
    pub fn decode(self, decoder: &Decoder<S>) -> Result<Scenario<S>, ParseEventError> {
        let mut timeline = Vec::with_capacity(self.timeline.len());
        for event in self.timeline {
            let event = decoder.decode(&event.name, &event.encoded)?;
            timeline.push(event);
        }

        Ok(Scenario {
            initial: self.initial,
            timeline,
        })
    }

Trait Implementations§

The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.