pub struct ConverterImpl<M = ()> {
pub destination: Type,
pub function: ItemFn,
pub pre_stages: Vec<Stage<M>>,
pub niches: Niches,
pub metadata: M,
pub subs: Vec<TypeKey>,
}Expand description
Result of resolving one converter — the wire (destination) type the rest of the registry sees, plus the complete generated function.
Invariant: function.sig.ident MUST be a deterministic function of the
(rust_type, destination) pair so that callers of this converter — both
other generated converters from the same adapter and any hand-written code
that knows the convention — can compute or look up the name.
Fields§
§destination: TypeWire/destination type. Other converters that ask “what’s the wire
form of this rust type?” read this. The actual function may return
a wrapped form (e.g. an adapter’s own Result-like envelope) — that
is the adapter’s internal calling convention; destination is the
value the wire carries on success.
function: ItemFnComplete function definition for the wire-facing stage. The
adapter owns the parameter list, return type, unsafe/pub
modifiers, lifetime parameters, and any attribute annotations.
For input direction this is the FIRST stage in execution order
(it takes the wire); for output direction this is the LAST stage
(it produces the wire).
pre_stages: Vec<Stage<M>>Rust-side stages that compose with Self::function to form
the full conversion chain. Default empty — a 1-stage converter
is just function.
Order is rust-side-first → function-side-last. Concretely:
- Input (wire → rust): chain runs
wire → function → pre_stages[0] → pre_stages[1] → … → pre_stages[N-1] → rust. - Output (rust → wire): chain runs
rust → pre_stages[N-1] → … → pre_stages[1] → pre_stages[0] → function → wire.
Each stage is fallible; how its Err arm is surfaced is adapter
specific and carried in Stage::metadata.
niches: NichesBit-patterns the wire type can represent but this converter never
produces (output) and rejects (input). Wrapper handlers like
Option<_> consume one slot for their own discriminant and
re-export the rest — see Niches for the cascade model.
Default is empty (no niche optimisation).
metadata: MAdapter-specific extras carried alongside the converter. Filled by
the same handler that produces destination / function /
niches, copied through into TypeEntry::metadata by the resolver,
and read by the adapter’s language-side emitters. Set this where you
build the converter, not in a side channel.
subs: Vec<TypeKey>Inner types this converter composed from — the types whose
input_entry/output_entry the adapter looked up to build a wrapper
(Option<X> → [X], Result<T,E> → [T, E], &T → [&T]). Empty
for a terminal converter (scalar, opaque handle, string) and for
a callback’s own converter (callback args are cross-direction — their
required-ness flows through the registry’s type-graph edges, not here). The
resolver copies these into TypeEntry::subs, which propagate_required
walks to mark reachable types required.
Identities, not spellings. They are looked up and walked, never
emitted — TypeEntry::subs
was already Vec<TypeKey> and the resolver keyed these on arrival, so
the spelling existed only to be converted. An adapter that composed the
inner type keys it (TypeKey::from_type); one that read it off the model
asks the reading (TypeRef::key), and names no escape to do it.
Trait Implementations§
Source§impl<M: Clone> Clone for ConverterImpl<M>
impl<M: Clone> Clone for ConverterImpl<M>
Source§fn clone(&self) -> ConverterImpl<M>
fn clone(&self) -> ConverterImpl<M>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<M = ()> !Send for ConverterImpl<M>
impl<M = ()> !Sync for ConverterImpl<M>
impl<M> Freeze for ConverterImpl<M>where
M: Freeze,
impl<M> RefUnwindSafe for ConverterImpl<M>where
M: RefUnwindSafe,
impl<M> Unpin for ConverterImpl<M>where
M: Unpin,
impl<M> UnsafeUnpin for ConverterImpl<M>where
M: UnsafeUnpin,
impl<M> UnwindSafe for ConverterImpl<M>where
M: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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 more