Skip to main content

SchemaRegistry

Struct SchemaRegistry 

Source
pub struct SchemaRegistry { /* private fields */ }
Expand description

Registry of all schema definitions exported by one domain schema module.

Implementations§

Source§

impl SchemaRegistry

Source

pub fn from_idl_bytes(bytes: &[u8]) -> Result<Self, SchemaIdlError>

Parses a schema registry from UTF-8 IDL JSON bytes.

Parsed names are promoted to 'static storage so the returned registry has the same lifetime shape as macro-generated registries. Repeatedly parsing unbounded IDL documents leaks those promoted strings; do not use this on a request path or hot reload loop.

Source

pub fn from_idl_json(json: &str) -> Result<Self, SchemaIdlError>

Parses a schema registry from IDL JSON text.

See SchemaRegistry::from_idl_bytes for the lifetime and leak behavior of parsed names.

Source§

impl SchemaRegistry

Source

pub fn to_idl_json(&self) -> String

Serializes this schema registry to stable IDL JSON.

Source§

impl SchemaRegistry

Source

pub fn new( schema_version: Version, record_defs: &[RecordDefinition], command_defs: &[CommandDefinition], event_defs: &[EventDefinition], enum_defs: &[EnumDefinition], ) -> Self

Builds a schema registry from static definitions.

Source

pub fn with_records( schema_version: Version, record_defs: &[RecordDefinition], ) -> Self

Builds a schema registry containing only record definitions.

Source

pub fn schema_version(&self) -> Version

Returns the schema module version.

Source

pub fn record_schema_fingerprint(&self) -> SchemaFingerprint

Returns the record schema fingerprint.

Source

pub fn command_schema_fingerprint(&self) -> SchemaFingerprint

Returns the command schema fingerprint.

Source

pub fn event_schema_fingerprint(&self) -> SchemaFingerprint

Returns the event schema fingerprint.

Source

pub fn types_schema_fingerprint(&self) -> SchemaFingerprint

Returns the enum/type schema fingerprint.

Source

pub fn identity(&self) -> SchemaIdentity

Returns the complete schema identity.

Source

pub fn try_get(&self, kind: RecordKind) -> Option<&RecordDefinition>

Returns a record definition by kind.

Source

pub fn record_defs(&self) -> impl Iterator<Item = &RecordDefinition> + '_

Iterates record definitions in stable kind order.

Source

pub fn try_get_command(&self, kind: u8) -> Option<&CommandDefinition>

Returns a command definition by kind.

Source

pub fn command_defs(&self) -> impl Iterator<Item = &CommandDefinition> + '_

Iterates command definitions in stable kind order.

Source

pub fn try_get_event(&self, kind: u8) -> Option<&EventDefinition>

Returns an event definition by kind.

Source

pub fn event_defs(&self) -> impl Iterator<Item = &EventDefinition> + '_

Iterates event definitions in stable kind order.

Source

pub fn enum_defs(&self) -> impl Iterator<Item = &EnumDefinition> + '_

Iterates enum definitions in stable name order.

Source

pub fn encode_pk(&self, kind: RecordKind, data: &[u8]) -> Option<PkBytes>

Encodes a primary key for a record buffer when the record supports it.

Source

pub fn supports_pk_encoding(&self, kind: RecordKind) -> bool

Returns whether the record kind has enough metadata for primary-key encoding.

Trait Implementations§

Source§

impl Clone for SchemaRegistry

Source§

fn clone(&self) -> SchemaRegistry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SchemaRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.