pub struct DefaultComponentCodec<C> { /* private fields */ }Expand description
Wraps an existing VersionedStateCodec as a ComponentStateCodec
without requiring a second codec implementation.
Implementations§
Source§impl<C> DefaultComponentCodec<C>
impl<C> DefaultComponentCodec<C>
Sourcepub const fn new(
schema: C,
codec_id: CodecId,
codec_version: CodecVersion,
restartability: RestartabilityDeclaration,
) -> Self
pub const fn new( schema: C, codec_id: CodecId, codec_version: CodecVersion, restartability: RestartabilityDeclaration, ) -> Self
Wraps schema with the codec identity/version and restartability
declaration this component requires.
Sourcepub fn with_codec_upgrades(self, upgrades: Vec<CodecVersionUpgrade>) -> Self
pub fn with_codec_upgrades(self, upgrades: Vec<CodecVersionUpgrade>) -> Self
Declares the directed codec-version upgrades this codec can apply.
Sourcepub const fn with_sensitivity(self, sensitivity: StateSensitivity) -> Self
pub const fn with_sensitivity(self, sensitivity: StateSensitivity) -> Self
Declares this component’s state sensitivity.
Trait Implementations§
Source§impl<T, C: VersionedStateCodec<T>> ComponentStateCodec<T> for DefaultComponentCodec<C>
impl<T, C: VersionedStateCodec<T>> ComponentStateCodec<T> for DefaultComponentCodec<C>
Source§fn codec_version(&self) -> CodecVersion
fn codec_version(&self) -> CodecVersion
Returns the version emitted when encoding.
Source§fn codec_upgrades(&self) -> &[CodecVersionUpgrade]
fn codec_upgrades(&self) -> &[CodecVersionUpgrade]
Declares the directed codec-version upgrades this codec can apply.
Source§fn sensitivity(&self) -> StateSensitivity
fn sensitivity(&self) -> StateSensitivity
Declares this component’s state sensitivity. Read more
Source§fn restartability(&self) -> RestartabilityDeclaration
fn restartability(&self) -> RestartabilityDeclaration
Declares whether this component can honestly claim restartability.
Source§impl<T, C: VersionedStateCodec<T>> VersionedStateCodec<T> for DefaultComponentCodec<C>
impl<T, C: VersionedStateCodec<T>> VersionedStateCodec<T> for DefaultComponentCodec<C>
Source§fn schema_id(&self) -> &StateSchemaId
fn schema_id(&self) -> &StateSchemaId
Returns the stable schema identifier.
Source§fn current_version(&self) -> StateSchemaVersion
fn current_version(&self) -> StateSchemaVersion
Returns the version emitted by
encode.Source§fn upgrades(&self) -> &[StateSchemaUpgrade]
fn upgrades(&self) -> &[StateSchemaUpgrade]
Declares the directed upgrades this codec can apply. Read more
Source§fn encode(&self, value: &T) -> Result<Vec<u8>, StateCodecError>
fn encode(&self, value: &T) -> Result<Vec<u8>, StateCodecError>
Encodes the current typed value as one JSON object. Read more
Source§fn decode(&self, payload: &[u8]) -> Result<T, StateCodecError>
fn decode(&self, payload: &[u8]) -> Result<T, StateCodecError>
Decodes one JSON-object payload already at
current_version. Read moreAuto Trait Implementations§
impl<C> Freeze for DefaultComponentCodec<C>where
C: Freeze,
impl<C> RefUnwindSafe for DefaultComponentCodec<C>where
C: RefUnwindSafe,
impl<C> Send for DefaultComponentCodec<C>where
C: Send,
impl<C> Sync for DefaultComponentCodec<C>where
C: Sync,
impl<C> Unpin for DefaultComponentCodec<C>where
C: Unpin,
impl<C> UnsafeUnpin for DefaultComponentCodec<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for DefaultComponentCodec<C>where
C: UnwindSafe,
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