Trait scale_decode::visitor::Visitor
source · [−]pub trait Visitor: Sized {
type Value;
type Error: From<DecodeError>;
Show 26 methods
fn visit_bool(
self,
value: bool,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_char(
self,
value: char,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_u8(
self,
value: u8,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_u16(
self,
value: u16,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_u32(
self,
value: u32,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_u64(
self,
value: u64,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_u128(
self,
value: u128,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_u256(
self,
value: &[u8; 32],
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_i8(
self,
value: i8,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_i16(
self,
value: i16,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_i32(
self,
value: i32,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_i64(
self,
value: i64,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_i128(
self,
value: i128,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_i256(
self,
value: &[u8; 32],
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_sequence(
self,
value: &mut Sequence<'_, '_>,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_composite(
self,
value: &mut Composite<'_, '_>,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_tuple(
self,
value: &mut Tuple<'_, '_>,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_str(
self,
value: Str<'_>,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_variant(
self,
value: &mut Variant<'_, '_>,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_array(
self,
value: &mut Array<'_, '_>,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_bitsequence(
self,
value: &mut BitSequence<'_>,
type_id: TypeId
) -> Result<Self::Value, Self::Error>;
fn visit_compact_u8(
self,
value: Compact<'_, '_, u8>,
type_id: TypeId
) -> Result<Self::Value, Self::Error> { ... }
fn visit_compact_u16(
self,
value: Compact<'_, '_, u16>,
type_id: TypeId
) -> Result<Self::Value, Self::Error> { ... }
fn visit_compact_u32(
self,
value: Compact<'_, '_, u32>,
type_id: TypeId
) -> Result<Self::Value, Self::Error> { ... }
fn visit_compact_u64(
self,
value: Compact<'_, '_, u64>,
type_id: TypeId
) -> Result<Self::Value, Self::Error> { ... }
fn visit_compact_u128(
self,
value: Compact<'_, '_, u128>,
type_id: TypeId
) -> Result<Self::Value, Self::Error> { ... }
}
Expand description
An implementation of the Visitor
trait can be passed to the crate::decode()
function, and is handed back values as they are encountered. It’s up to the implementation
to decide what to do with these values.
Required Associated Types
The type of the value to hand back from the crate::decode()
function.
sourcetype Error: From<DecodeError>
type Error: From<DecodeError>
The error type (which we must be able to convert DecodeError
s into, to
handle any internal errors that crop up trying to decode things).
Required Methods
Called when a bool is seen in the input bytes.
Called when a bool is seen in the input bytes.
Called when a u8 is seen in the input bytes.
Called when a u16 is seen in the input bytes.
Called when a u32 is seen in the input bytes.
Called when a u64 is seen in the input bytes.
Called when a u128 is seen in the input bytes.
Called when a u256 is seen in the input bytes.
Called when an i8 is seen in the input bytes.
Called when an i16 is seen in the input bytes.
Called when an i32 is seen in the input bytes.
Called when an i64 is seen in the input bytes.
Called when an i128 is seen in the input bytes.
Called when an i256 is seen in the input bytes.
Called when a sequence of values is seen in the input bytes.
Called when a composite value is seen in the input bytes.
Called when a tuple of values is seen in the input bytes.
Called when a string value is seen in the input bytes.
Called when a variant is seen in the input bytes.
Called when an array is seen in the input bytes.
sourcefn visit_bitsequence(
self,
value: &mut BitSequence<'_>,
type_id: TypeId
) -> Result<Self::Value, Self::Error>
fn visit_bitsequence(
self,
value: &mut BitSequence<'_>,
type_id: TypeId
) -> Result<Self::Value, Self::Error>
Called when a bit sequence is seen in the input bytes.
Provided Methods
Called when a compact encoded u8 is seen in the input bytes.
Called when a compact encoded u16 is seen in the input bytes.
Called when a compact encoded u32 is seen in the input bytes.
Called when a compact encoded u64 is seen in the input bytes.