pub struct EnvTypesTranscoder { /* private fields */ }
Expand description
Provides custom encoding and decoding for predefined environment types.
Implementations§
Source§impl EnvTypesTranscoder
impl EnvTypesTranscoder
Sourcepub fn new(
encoders: HashMap<u32, Box<dyn CustomTypeEncoder>>,
decoders: HashMap<u32, Box<dyn CustomTypeDecoder>>,
) -> Self
pub fn new( encoders: HashMap<u32, Box<dyn CustomTypeEncoder>>, decoders: HashMap<u32, Box<dyn CustomTypeDecoder>>, ) -> Self
Construct an EnvTypesTranscoder
from the given type registry.
Sourcepub fn try_encode<O>(
&self,
type_id: u32,
value: &Value,
output: &mut O,
) -> Result<bool>where
O: Output,
pub fn try_encode<O>(
&self,
type_id: u32,
value: &Value,
output: &mut O,
) -> Result<bool>where
O: Output,
If the given type id is for a type with custom encoding, encodes the given value
with the custom encoder and returns true
. Otherwise returns false
.
§Errors
- If the custom encoding fails.
Sourcepub fn try_decode(
&self,
type_id: u32,
input: &mut &[u8],
) -> Result<Option<Value>>
pub fn try_decode( &self, type_id: u32, input: &mut &[u8], ) -> Result<Option<Value>>
If the given type lookup id is for an environment type with custom
decoding, decodes the given input with the custom decoder and returns
Some(value)
. Otherwise returns None
.
§Errors
- If the custom decoding fails.
Trait Implementations§
Source§impl Default for EnvTypesTranscoder
impl Default for EnvTypesTranscoder
Source§fn default() -> EnvTypesTranscoder
fn default() -> EnvTypesTranscoder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for EnvTypesTranscoder
impl !RefUnwindSafe for EnvTypesTranscoder
impl Send for EnvTypesTranscoder
impl Sync for EnvTypesTranscoder
impl Unpin for EnvTypesTranscoder
impl !UnwindSafe for EnvTypesTranscoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
Source§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Given the context attached to a nom error, and given the original
input to the nom parser, extract more the useful context information. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
Source§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Given the original input, as well as the context reported by nom,
recreate a context in the original string where the error occurred. Read more
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of
T
. Read moreSource§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of
T
.