SystemContext

Struct SystemContext 

Source
pub struct SystemContext<A, M> { /* private fields */ }
Available on crate feature alloc only.
Expand description

A rich context dynamically allocating space using the system allocator.

Implementations§

Source§

impl<A, M> SystemContext<A, M>

Source

pub fn new(alloc: A) -> Self

Construct a new context which uses allocations to store arbitrary amounts of diagnostics about decoding.

Or at least until we run out of memory.

Source

pub fn include_type(&mut self) -> &mut Self

Configure the context to visualize type information, and not just variant and fields.

Source

pub fn report(&self) -> Report<'_>

Generate a line-separated report of all collected errors.

Source

pub fn errors(&self) -> Errors<'_>

Iterate over all collected errors.

Trait Implementations§

Source§

impl<A, M> Context for SystemContext<A, M>
where A: Allocator,

Source§

type Mode = M

Mode of the context.
Source§

type Error = ErrorMarker

Error produced by context.
Source§

type Mark = usize

A mark during processing.
Source§

type Buf<'this> = <A as Allocator>::Buf<'this> where Self: 'this

A growable buffer.
Source§

type BufString<'this> = BufString<<A as Allocator>::Buf<'this>> where Self: 'this

An allocated buffer containing a valid string.
Source§

fn clear(&self)

Clear the state of the context, allowing it to be re-used.
Source§

fn alloc(&self) -> Option<Self::Buf<'_>>

Allocate a buffer.
Source§

fn collect_string<T>( &self, value: &T, ) -> Result<Self::BufString<'_>, Self::Error>
where T: ?Sized + Display,

Collect and allocate a string from a Display implementation.
Source§

fn custom<T>(&self, message: T) -> Self::Error
where T: 'static + Send + Sync + Display + Debug,

Report a custom error, which is not encapsulated by the error type expected by the context. This is essentially a type-erased way of reporting error-like things out from the context.
Source§

fn message<T>(&self, message: T) -> Self::Error
where T: Display,

Report a message as an error. Read more
Source§

fn marked_message<T>(&self, mark: Self::Mark, message: T) -> Self::Error
where T: Display,

Report an error based on a mark. Read more
Source§

fn marked_custom<T>(&self, mark: Self::Mark, message: T) -> Self::Error
where T: 'static + Send + Sync + Display + Debug,

Report an error based on a mark. Read more
Source§

fn mark(&self) -> Self::Mark

Return a mark which acts as a checkpoint at the current encoding state. Read more
Source§

fn advance(&self, n: usize)

Advance the context by n bytes of input. Read more
Source§

fn enter_named_field<T>(&self, name: &'static str, _: &T)
where T: ?Sized + Display,

Trace that we’ve entered the given named field. Read more
Source§

fn enter_unnamed_field<T>(&self, index: u32, _: &T)
where T: ?Sized + Display,

Trace that we’ve entered the given unnamed field. Read more
Source§

fn leave_field(&self)

Trace that we’ve left the last field that was entered. Read more
Source§

fn enter_struct(&self, name: &'static str)

Indicate that we’ve entered a struct with the given name. Read more
Source§

fn leave_struct(&self)

Trace that we’ve left the last struct that was entered.
Source§

fn enter_enum(&self, name: &'static str)

Indicate that we’ve entered an enum with the given name. Read more
Source§

fn leave_enum(&self)

Trace that we’ve left the last enum that was entered.
Source§

fn enter_variant<T>(&self, name: &'static str, _: T)

Trace that we’ve entered the given variant in an enum. Read more
Source§

fn leave_variant(&self)

Trace that we’ve left the last variant that was entered. Read more
Source§

fn enter_sequence_index(&self, index: usize)

Trace a sequence field.
Source§

fn leave_sequence_index(&self)

Trace that we’ve left the last sequence index that was entered. Read more
Source§

fn enter_map_key<T>(&self, field: T)
where T: Display,

Trace a that a map key has been entered.
Source§

fn leave_map_key(&self)

Trace that we’ve left the last map field that was entered. Read more
Source§

fn decode<'de, T, D>(&self, decoder: D) -> Result<T, Self::Error>
where T: Decode<'de, Self::Mode>, D: Decoder<'de, Cx = Self, Mode = Self::Mode, Error = Self::Error>,

Decode the given input using the associated mode.
Source§

fn decode_unsized<'de, T, D, F, O>( &self, decoder: D, f: F, ) -> Result<O, Self::Error>
where T: DecodeUnsized<'de, Self::Mode> + ?Sized, D: Decoder<'de, Cx = Self, Mode = Self::Mode, Error = Self::Error>, F: FnOnce(&T) -> Result<O, <D as Decoder<'de>>::Error>,

Decode the given unsized value using the associated mode.
Source§

fn decode_bytes<'de, T, D>(&self, decoder: D) -> Result<T, Self::Error>
where T: DecodeBytes<'de, Self::Mode>, D: Decoder<'de, Cx = Self, Mode = Self::Mode, Error = Self::Error>,

Decode the given input as bytes using the associated mode.
Source§

fn decode_unsized_bytes<'de, T, D, F, O>( &self, decoder: D, f: F, ) -> Result<O, Self::Error>
where T: DecodeUnsizedBytes<'de, Self::Mode> + ?Sized, D: Decoder<'de, Cx = Self, Mode = Self::Mode, Error = Self::Error>, F: FnOnce(&T) -> Result<O, <D as Decoder<'de>>::Error>,

Decode the given unsized value as bytes using the associated mode.
Source§

fn map<T>(&self) -> impl FnOnce(T) -> Self::Error
where T: 'static + Send + Sync + Error,

Generate a map function which maps an error using the custom function.
Source§

fn map_message<T>(&self) -> impl FnOnce(T) -> Self::Error
where T: Display,

Generate a map function which maps an error using the message function.
Source§

fn invalid_variant_tag<T>(&self, _: &'static str, tag: &T) -> Self::Error
where T: Debug + ?Sized,

Report that an invalid variant tag was encountered.
Source§

fn expected_tag<T>(&self, _: &'static str, tag: &T) -> Self::Error
where T: Debug + ?Sized,

The value for the given tag could not be collected.
Source§

fn uninhabitable(&self, _: &'static str) -> Self::Error

Trying to decode an uninhabitable type.
Source§

fn invalid_field_tag<T>(&self, _: &'static str, tag: &T) -> Self::Error
where T: Debug + ?Sized,

Encountered an unsupported field tag.
Source§

fn expected_field_adjacent<T, C>( &self, _: &'static str, tag: &T, content: &C, ) -> Self::Error
where T: Debug + ?Sized, C: Debug + ?Sized,

Expected another field to decode.
Source§

fn missing_adjacent_tag<T>(&self, _: &'static str, tag: &T) -> Self::Error
where T: Debug + ?Sized,

Missing adjacent tag when decoding.
Source§

fn invalid_field_string_tag( &self, _: &'static str, field: Self::Buf<'_>, ) -> Self::Error

Encountered an unsupported field tag.
Source§

fn missing_variant_field<T>(&self, name: &'static str, tag: &T) -> Self::Error
where T: Debug + ?Sized,

Missing variant field required to decode.
Source§

fn missing_variant_tag(&self, name: &'static str) -> Self::Error

Indicate that a variant tag could not be determined.
Source§

fn invalid_variant_field_tag<V, T>( &self, name: &'static str, variant: &V, tag: &T, ) -> Self::Error
where V: Debug + ?Sized, T: Debug + ?Sized,

Encountered an unsupported variant field.
Source§

fn alloc_failed(&self) -> Self::Error

Missing variant field required to decode.

Auto Trait Implementations§

§

impl<A, M> !Freeze for SystemContext<A, M>

§

impl<A, M> !RefUnwindSafe for SystemContext<A, M>

§

impl<A, M> Send for SystemContext<A, M>
where A: Send, M: Send,

§

impl<A, M> !Sync for SystemContext<A, M>

§

impl<A, M> Unpin for SystemContext<A, M>
where A: Unpin, M: Unpin,

§

impl<A, M> UnwindSafe for SystemContext<A, M>
where A: UnwindSafe, M: UnwindSafe,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.