VisitorWithCrateError

Struct VisitorWithCrateError 

Source
pub struct VisitorWithCrateError<V>(pub V);
Expand description

Some Visitor implementations may want to return an error type other than crate::Error, which means that they would not be automatically compatible with crate::IntoVisitor, which requires visitors that do return crate::Error errors.

As long as the error type of the visitor implementation can be converted into crate::Error via Into, the visitor implementation can be wrapped in this VisitorWithCrateError struct to make it work with crate::IntoVisitor.

Tuple Fields§

§0: V

Trait Implementations§

Source§

impl<V: Clone> Clone for VisitorWithCrateError<V>

Source§

fn clone(&self) -> VisitorWithCrateError<V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug> Debug for VisitorWithCrateError<V>

Source§

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

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

impl<V: PartialEq> PartialEq for VisitorWithCrateError<V>

Source§

fn eq(&self, other: &VisitorWithCrateError<V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: Visitor> Visitor for VisitorWithCrateError<V>
where V::Error: Into<Error>,

Source§

type Value<'scale, 'resolver> = <V as Visitor>::Value<'scale, 'resolver>

The type of the value to hand back from the decode_with_visitor() function.
Source§

type Error = Error

The error type (which we must be able to convert a combination of Self and DecodeErrors into, to handle any internal errors that crop up trying to decode things).
Source§

type TypeResolver = <V as Visitor>::TypeResolver

The thing we’ll use to resolve type IDs into concrete types.
Source§

fn unchecked_decode_as_type<'scale, 'resolver>( self, input: &mut &'scale [u8], type_id: TypeIdFor<Self>, types: &'resolver Self::TypeResolver, ) -> DecodeAsTypeResult<Self, Result<Self::Value<'scale, 'resolver>, Self::Error>>

This method is called immediately upon running decode_with_visitor(). By default we ignore this call and return our visitor back (ie [DecodeAsTypeResult::Skipped(visitor)]). If you choose to do some decoding at this stage, return [DecodeAsTypeResult::Decoded(result)]. In either case, any bytes that you consume from the input (by altering what it points to) will be consumed for any subsequent visiting. Read more
Source§

fn visit_unexpected<'scale, 'resolver>( self, unexpected: Unexpected, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

This is called when a visitor function that you’ve not provided an implementation is called. You are provided an enum value corresponding to the function call, and can decide what to return in this case. The default is to return an error to announce the unexpected value.
Source§

fn visit_bool<'scale, 'resolver>( self, _value: bool, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when a bool is seen in the input bytes.
Source§

fn visit_char<'scale, 'resolver>( self, _value: char, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when a char is seen in the input bytes.
Source§

fn visit_u8<'scale, 'resolver>( self, _value: u8, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when a u8 is seen in the input bytes.
Source§

fn visit_u16<'scale, 'resolver>( self, _value: u16, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when a u16 is seen in the input bytes.
Source§

fn visit_u32<'scale, 'resolver>( self, _value: u32, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when a u32 is seen in the input bytes.
Source§

fn visit_u64<'scale, 'resolver>( self, _value: u64, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when a u64 is seen in the input bytes.
Source§

fn visit_u128<'scale, 'resolver>( self, _value: u128, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when a u128 is seen in the input bytes.
Source§

fn visit_u256<'resolver>( self, _value: &[u8; 32], _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'_, 'resolver>, Self::Error>

Called when a u256 is seen in the input bytes.
Source§

fn visit_i8<'scale, 'resolver>( self, _value: i8, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when an i8 is seen in the input bytes.
Source§

fn visit_i16<'scale, 'resolver>( self, _value: i16, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when an i16 is seen in the input bytes.
Source§

fn visit_i32<'scale, 'resolver>( self, _value: i32, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when an i32 is seen in the input bytes.
Source§

fn visit_i64<'scale, 'resolver>( self, _value: i64, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when an i64 is seen in the input bytes.
Source§

fn visit_i128<'scale, 'resolver>( self, _value: i128, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when an i128 is seen in the input bytes.
Source§

fn visit_i256<'resolver>( self, _value: &[u8; 32], _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'_, 'resolver>, Self::Error>

Called when an i256 is seen in the input bytes.
Source§

fn visit_sequence<'scale, 'resolver>( self, _value: &mut Sequence<'scale, 'resolver, Self::TypeResolver>, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when a sequence of values is seen in the input bytes.
Source§

fn visit_composite<'scale, 'resolver>( self, _value: &mut Composite<'scale, 'resolver, Self::TypeResolver>, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when a composite value is seen in the input bytes.
Source§

fn visit_tuple<'scale, 'resolver>( self, _value: &mut Tuple<'scale, 'resolver, Self::TypeResolver>, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when a tuple of values is seen in the input bytes.
Source§

fn visit_str<'scale, 'resolver>( self, _value: &mut Str<'scale>, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when a string value is seen in the input bytes.
Source§

fn visit_variant<'scale, 'resolver>( self, _value: &mut Variant<'scale, 'resolver, Self::TypeResolver>, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when a variant is seen in the input bytes.
Source§

fn visit_array<'scale, 'resolver>( self, _value: &mut Array<'scale, 'resolver, Self::TypeResolver>, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when an array is seen in the input bytes.
Source§

fn visit_bitsequence<'scale, 'resolver>( self, _value: &mut BitSequence<'scale>, _type_id: TypeIdFor<Self>, ) -> Result<Self::Value<'scale, 'resolver>, Self::Error>

Called when a bit sequence is seen in the input bytes.
Source§

impl<V: Copy> Copy for VisitorWithCrateError<V>

Source§

impl<V: Eq> Eq for VisitorWithCrateError<V>

Source§

impl<V> StructuralPartialEq for VisitorWithCrateError<V>

Auto Trait Implementations§

§

impl<V> Freeze for VisitorWithCrateError<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for VisitorWithCrateError<V>
where V: RefUnwindSafe,

§

impl<V> Send for VisitorWithCrateError<V>
where V: Send,

§

impl<V> Sync for VisitorWithCrateError<V>
where V: Sync,

§

impl<V> Unpin for VisitorWithCrateError<V>
where V: Unpin,

§

impl<V> UnwindSafe for VisitorWithCrateError<V>
where V: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.