Skip to main content

JsonPayloadDecoderRegistry

Struct JsonPayloadDecoderRegistry 

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

Heterogeneous per-key payload decoder registry.

One registry may contain the union of keys used by several output streams. Coverage therefore requires every selected key but permits additional registrations. Keys are exact and are not trimmed or case-normalized.

This type is intentionally non-Clone because registered decoders may own caches, handles, or synchronization state with unknown clone semantics.

Implementations§

Source§

impl JsonPayloadDecoderRegistry

Source

pub fn new() -> Self

Creates an empty registry.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates an empty registry with capacity for at least capacity keys.

Source

pub fn with_json_field<T>( self, key: impl Into<String>, ) -> Result<Self, StorageError>
where T: DeserializeOwned + Serialize + Clone + Send + 'static,

Adds a field decoded directly through Serde JSON into T.

This is the concise path for payload types whose JSON representation already matches their Rust representation. Specialized decoders remain available through JsonPayloadDecoderRegistry::register_for_field when conversion requires configuration, validation, or a different wire shape.

§Errors

Returns the same empty-key or duplicate-key errors as JsonPayloadDecoderRegistry::register_for_field. Payload parse failures are reported later with their field context by the reader.

Source

pub fn register_for_field<T, D>( &mut self, key: impl Into<String>, decoder: D, ) -> Result<(), StorageError>
where T: Serialize + Clone + Send + 'static, D: JsonPayloadDecoder<T>,

Registers one typed decoder under one exact state field key.

Successful decoded values are moved directly into SystemState; the adapter never invokes T::clone.

§Errors

Returns StorageError::InvalidConfiguration for an empty key and StorageError::DuplicateDecoder for an existing key. The incoming decoder is dropped on either configuration error.

Source

pub fn len(&self) -> usize

Returns the number of registered field keys.

Source

pub fn is_empty(&self) -> bool

Reports whether no payload decoder is registered.

Source

pub fn has_decoder_for_field(&self, key: &str) -> bool

Reports whether an exact field key has a registered decoder.

Source

pub fn registered_field_names(&self) -> impl ExactSizeIterator<Item = &str>

Iterates registered keys in unspecified hash-map order.

Reader dispatch never uses this order. Callers needing stable display should sort the returned strings.

Trait Implementations§

Source§

impl Debug for JsonPayloadDecoderRegistry

Source§

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

Formats sorted keys without exposing decoder internals or payloads.

Source§

impl Default for JsonPayloadDecoderRegistry

Source§

fn default() -> JsonPayloadDecoderRegistry

Returns the “default value” for a type. 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> 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> Same for T

Source§

type Output = T

Should always be Self
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.