pub struct WireTypeRegistry { /* private fields */ }Expand description
A program-derived registry of every struct/enum schema, shared by both ends of a Logos↔Logos link (each side builds it from the SAME program type definitions). Every type gets a stable small id — canonical by fingerprint, so declaration order is irrelevant and sender + receiver always agree. The codec ships the id instead of the type/field NAMES, and the receiver — running the same program — resolves it. This is the “duh, you use that” default that drops names off the wire entirely.
Implementations§
Source§impl WireTypeRegistry
impl WireTypeRegistry
Sourcepub fn new(schemas: Vec<(String, Vec<String>)>) -> Self
pub fn new(schemas: Vec<(String, Vec<String>)>) -> Self
Build from (type_name, field_names) struct schemas. Field names are sorted (the
codec’s canonical order), duplicates collapsed, and the set ordered by fingerprint
so two peers that declared the same types in any order assign identical ids.
Sourcepub fn with_enums(self, enums: Vec<(String, Vec<String>)>) -> Self
pub fn with_enums(self, enums: Vec<(String, Vec<String>)>) -> Self
Add enum types (type_name, ordered_constructors). Constructor order is preserved
(the wire ships a constructor index); the enum set is ordered by fingerprint so
both peers assign identical enum ids regardless of declaration order.
Sourcepub fn epoch(&self) -> u64
pub fn epoch(&self) -> u64
A content hash of this registry’s WHOLE type set — the registry EPOCH advertised in the
handshake. Two peers that declared the SAME struct + enum types (in any order) compute the same
epoch, so when their epochs MATCH they may elide type NAMES from the wire (type-id). 0 for an
empty registry — no shared types, so never elide. Deterministic: folds the per-type
fingerprints, which are already in canonical fingerprint order.
Trait Implementations§
Source§impl Clone for WireTypeRegistry
impl Clone for WireTypeRegistry
Source§fn clone(&self) -> WireTypeRegistry
fn clone(&self) -> WireTypeRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WireTypeRegistry
impl Debug for WireTypeRegistry
Source§impl Default for WireTypeRegistry
impl Default for WireTypeRegistry
Source§fn default() -> WireTypeRegistry
fn default() -> WireTypeRegistry
Auto Trait Implementations§
impl Freeze for WireTypeRegistry
impl RefUnwindSafe for WireTypeRegistry
impl Send for WireTypeRegistry
impl Sync for WireTypeRegistry
impl Unpin for WireTypeRegistry
impl UnsafeUnpin for WireTypeRegistry
impl UnwindSafe for WireTypeRegistry
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.