pub trait ResolvedTypeVisitor<'resolver>: Sized {
type TypeId: TypeId + 'static;
type Value;
// Required method
fn visit_unhandled(self, kind: UnhandledKind) -> Self::Value;
// Provided methods
fn visit_not_found(self) -> Self::Value { ... }
fn visit_composite<Path, Fields>(
self,
_path: Path,
_fields: Fields,
) -> Self::Value
where Path: PathIter<'resolver>,
Fields: FieldIter<'resolver, Self::TypeId> { ... }
fn visit_variant<Path, Fields, Var>(
self,
_path: Path,
_variants: Var,
) -> Self::Value
where Path: PathIter<'resolver>,
Fields: FieldIter<'resolver, Self::TypeId>,
Var: VariantIter<'resolver, Fields> { ... }
fn visit_sequence<Path>(
self,
_path: Path,
_type_id: Self::TypeId,
) -> Self::Value
where Path: PathIter<'resolver> { ... }
fn visit_array(self, _type_id: Self::TypeId, _len: usize) -> Self::Value { ... }
fn visit_tuple<TypeIds>(self, _type_ids: TypeIds) -> Self::Value
where TypeIds: ExactSizeIterator<Item = Self::TypeId> { ... }
fn visit_primitive(self, _primitive: Primitive) -> Self::Value { ... }
fn visit_compact(self, _type_id: Self::TypeId) -> Self::Value { ... }
fn visit_bit_sequence(
self,
_store_format: BitsStoreFormat,
_order_format: BitsOrderFormat,
) -> Self::Value { ... }
}
Expand description
A glorified set of callbacks, exactly one of which will fire depending on the outcome of calling
TypeResolver::resolve_type()
. These don’t typically need to be implemented by the user, and
instead are implemented internally in eg scale-decode
to drive the decoding of types.
The lifetime held by this trait is the lifetime of the type resolver. Various inputs to the callbacks are thus bound by this lifetime, and it’s possible to return values which contain this lifetime.
Required Associated Types§
Sourcetype TypeId: TypeId + 'static
type TypeId: TypeId + 'static
The type ID type that the TypeResolver
is using.
Required Methods§
Sourcefn visit_unhandled(self, kind: UnhandledKind) -> Self::Value
fn visit_unhandled(self, kind: UnhandledKind) -> Self::Value
Called when the actual method to be called was not implemented.
Provided Methods§
Sourcefn visit_not_found(self) -> Self::Value
fn visit_not_found(self) -> Self::Value
Called when the type ID passed to TypeResolver::resolve_type()
was not found.
Sourcefn visit_composite<Path, Fields>(
self,
_path: Path,
_fields: Fields,
) -> Self::Value
fn visit_composite<Path, Fields>( self, _path: Path, _fields: Fields, ) -> Self::Value
Called when the type ID corresponds to a composite type. This is provided an iterator over each of the fields and their type IDs that the composite type contains.
Sourcefn visit_variant<Path, Fields, Var>(
self,
_path: Path,
_variants: Var,
) -> Self::Valuewhere
Path: PathIter<'resolver>,
Fields: FieldIter<'resolver, Self::TypeId>,
Var: VariantIter<'resolver, Fields>,
fn visit_variant<Path, Fields, Var>(
self,
_path: Path,
_variants: Var,
) -> Self::Valuewhere
Path: PathIter<'resolver>,
Fields: FieldIter<'resolver, Self::TypeId>,
Var: VariantIter<'resolver, Fields>,
Called when the type ID corresponds to a variant type. This is provided the list of variants (and for each variant, the fields within it) that the type could be encoded as.
Sourcefn visit_sequence<Path>(
self,
_path: Path,
_type_id: Self::TypeId,
) -> Self::Valuewhere
Path: PathIter<'resolver>,
fn visit_sequence<Path>(
self,
_path: Path,
_type_id: Self::TypeId,
) -> Self::Valuewhere
Path: PathIter<'resolver>,
Called when the type ID corresponds to a sequence of values of some type ID (which is provided as an argument here). The length of the sequence is compact encoded first.
Sourcefn visit_array(self, _type_id: Self::TypeId, _len: usize) -> Self::Value
fn visit_array(self, _type_id: Self::TypeId, _len: usize) -> Self::Value
Called when the type ID corresponds to an array of values of some type ID (which is provided as an argument here). The length of the array is known at compile time and is also provided.
Sourcefn visit_tuple<TypeIds>(self, _type_ids: TypeIds) -> Self::Valuewhere
TypeIds: ExactSizeIterator<Item = Self::TypeId>,
fn visit_tuple<TypeIds>(self, _type_ids: TypeIds) -> Self::Valuewhere
TypeIds: ExactSizeIterator<Item = Self::TypeId>,
Called when the type ID corresponds to a tuple of values whose type IDs are provided here.
Sourcefn visit_primitive(self, _primitive: Primitive) -> Self::Value
fn visit_primitive(self, _primitive: Primitive) -> Self::Value
Called when the type ID corresponds to some primitive type. The exact primitive type is provided in th form of an enum.
Sourcefn visit_compact(self, _type_id: Self::TypeId) -> Self::Value
fn visit_compact(self, _type_id: Self::TypeId) -> Self::Value
Called when the type ID corresponds to a compact encoded type. The type ID of the inner type is provided.
Sourcefn visit_bit_sequence(
self,
_store_format: BitsStoreFormat,
_order_format: BitsOrderFormat,
) -> Self::Value
fn visit_bit_sequence( self, _store_format: BitsStoreFormat, _order_format: BitsOrderFormat, ) -> Self::Value
Called when the type ID corresponds to a bit sequence, whose store and order types are given.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.