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
impl JsonPayloadDecoderRegistry
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty registry with capacity for at least capacity keys.
Sourcepub fn with_json_field<T>(
self,
key: impl Into<String>,
) -> Result<Self, StorageError>
pub fn with_json_field<T>( self, key: impl Into<String>, ) -> Result<Self, StorageError>
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.
Sourcepub fn register_for_field<T, D>(
&mut self,
key: impl Into<String>,
decoder: D,
) -> Result<(), StorageError>
pub fn register_for_field<T, D>( &mut self, key: impl Into<String>, decoder: D, ) -> Result<(), StorageError>
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.
Sourcepub fn has_decoder_for_field(&self, key: &str) -> bool
pub fn has_decoder_for_field(&self, key: &str) -> bool
Reports whether an exact field key has a registered decoder.
Sourcepub fn registered_field_names(&self) -> impl ExactSizeIterator<Item = &str>
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.