Skip to main content

PathLayer

Struct PathLayer 

Source
pub struct PathLayer { /* private fields */ }
Expand description

A layer that tracks the current Path in the state.

The layer works for serialization (it implements deser::ser::Layer) and deserialization (it implements deser::de::Layer). It attaches the path to errors which do not have one (see Error::attachment).

During deserialization the path is also correct for values which are buffered and replayed (for instance by internally tagged enums).

Layers see the path of the current event if they are added after the path layer. This also means that the errors of such layers get the path of the event they reject attached, so the path layer should typically be added first.

Implementations§

Source§

impl PathLayer

Source

pub fn new() -> PathLayer

Creates a new path layer.

Trait Implementations§

Source§

impl Debug for PathLayer

Source§

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

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

impl Default for PathLayer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Layer for PathLayer

Tracks the path during deserialization.

The path of a value is set before the value is passed on, so that the sinks can access it. Containers push a segment for their items after they started and pop it before they end, so the path of a container is its own path while it’s finished.

Source§

fn event<'de>( &mut self, event: LayerEvent<'_, 'de>, next: &mut Next<'_, 'de>, ) -> Result<(), Error>

Processes an event. Read more
Source§

impl Layer for PathLayer

Tracks the path during serialization.

The format receives the events with the path of the value they belong to (map keys with the path of the map). After an event was passed on, the path is updated for the value that follows, so that its Serialize implementation can access it.

Source§

fn event(&mut self, event: Event<'_>, next: &mut Next<'_>) -> Result<(), Error>

Processes an event. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.