pub struct SchemaRegistry { /* private fields */ }Expand description
Registry of all schema definitions exported by one domain schema module.
Implementations§
Source§impl SchemaRegistry
impl SchemaRegistry
Sourcepub fn from_idl_bytes(bytes: &[u8]) -> Result<Self, SchemaIdlError>
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.
Sourcepub fn from_idl_json(json: &str) -> Result<Self, SchemaIdlError>
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
impl SchemaRegistry
Sourcepub fn to_idl_json(&self) -> String
pub fn to_idl_json(&self) -> String
Serializes this schema registry to stable IDL JSON.
Source§impl SchemaRegistry
impl SchemaRegistry
Sourcepub fn new(
schema_version: Version,
record_defs: &[RecordDefinition],
command_defs: &[CommandDefinition],
event_defs: &[EventDefinition],
enum_defs: &[EnumDefinition],
) -> Self
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.
Sourcepub fn with_records(
schema_version: Version,
record_defs: &[RecordDefinition],
) -> Self
pub fn with_records( schema_version: Version, record_defs: &[RecordDefinition], ) -> Self
Builds a schema registry containing only record definitions.
Sourcepub fn schema_version(&self) -> Version
pub fn schema_version(&self) -> Version
Returns the schema module version.
Sourcepub fn record_schema_fingerprint(&self) -> SchemaFingerprint
pub fn record_schema_fingerprint(&self) -> SchemaFingerprint
Returns the record schema fingerprint.
Sourcepub fn command_schema_fingerprint(&self) -> SchemaFingerprint
pub fn command_schema_fingerprint(&self) -> SchemaFingerprint
Returns the command schema fingerprint.
Sourcepub fn event_schema_fingerprint(&self) -> SchemaFingerprint
pub fn event_schema_fingerprint(&self) -> SchemaFingerprint
Returns the event schema fingerprint.
Sourcepub fn types_schema_fingerprint(&self) -> SchemaFingerprint
pub fn types_schema_fingerprint(&self) -> SchemaFingerprint
Returns the enum/type schema fingerprint.
Sourcepub fn identity(&self) -> SchemaIdentity
pub fn identity(&self) -> SchemaIdentity
Returns the complete schema identity.
Sourcepub fn try_get(&self, kind: RecordKind) -> Option<&RecordDefinition>
pub fn try_get(&self, kind: RecordKind) -> Option<&RecordDefinition>
Returns a record definition by kind.
Sourcepub fn record_defs(&self) -> impl Iterator<Item = &RecordDefinition> + '_
pub fn record_defs(&self) -> impl Iterator<Item = &RecordDefinition> + '_
Iterates record definitions in stable kind order.
Sourcepub fn try_get_command(&self, kind: u8) -> Option<&CommandDefinition>
pub fn try_get_command(&self, kind: u8) -> Option<&CommandDefinition>
Returns a command definition by kind.
Sourcepub fn command_defs(&self) -> impl Iterator<Item = &CommandDefinition> + '_
pub fn command_defs(&self) -> impl Iterator<Item = &CommandDefinition> + '_
Iterates command definitions in stable kind order.
Sourcepub fn try_get_event(&self, kind: u8) -> Option<&EventDefinition>
pub fn try_get_event(&self, kind: u8) -> Option<&EventDefinition>
Returns an event definition by kind.
Sourcepub fn event_defs(&self) -> impl Iterator<Item = &EventDefinition> + '_
pub fn event_defs(&self) -> impl Iterator<Item = &EventDefinition> + '_
Iterates event definitions in stable kind order.
Sourcepub fn enum_defs(&self) -> impl Iterator<Item = &EnumDefinition> + '_
pub fn enum_defs(&self) -> impl Iterator<Item = &EnumDefinition> + '_
Iterates enum definitions in stable name order.
Sourcepub fn encode_pk(&self, kind: RecordKind, data: &[u8]) -> Option<PkBytes>
pub fn encode_pk(&self, kind: RecordKind, data: &[u8]) -> Option<PkBytes>
Encodes a primary key for a record buffer when the record supports it.
Sourcepub fn supports_pk_encoding(&self, kind: RecordKind) -> bool
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
impl Clone for SchemaRegistry
Source§fn clone(&self) -> SchemaRegistry
fn clone(&self) -> SchemaRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more