pub struct Schema { /* private fields */ }Expand description
A validated schema: canonical type table, cached canonical bytes, content id, and precomputed struct layouts.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn id(&self) -> u128
pub fn id(&self) -> u128
128-bit content hash of the canonical schema bytes (truncated SHA-256,
see crate::hash). Acts as a content-address / cache key; wide
enough (~2^64 birthday resistance) to resist schema-confusion.
pub fn canonical_bytes(&self) -> &[u8] ⓘ
pub fn root_index(&self) -> u16
pub fn type_count(&self) -> u16
pub fn type_def(&self, index: u16) -> Option<&TypeDef>
pub fn type_name(&self, index: u16) -> &str
Sourcepub fn find_field(
&self,
struct_index: u16,
id: u16,
) -> Option<(usize, &FieldDef)>
pub fn find_field( &self, struct_index: u16, id: u16, ) -> Option<(usize, &FieldDef)>
Position (in ID-sorted order) and definition of a field, by ID.
Sourcepub fn from_canonical(bytes: &[u8]) -> Result<Schema>
pub fn from_canonical(bytes: &[u8]) -> Result<Schema>
Decode a schema from its canonical bytes (e.g. the inline schema region of a message). Rejects malformed and non-canonical encodings.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
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
Mutably borrows from an owned value. Read more