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,
) -> DefaultComponentCodec<C>
pub const fn new( schema: C, codec_id: CodecId, codec_version: CodecVersion, restartability: RestartabilityDeclaration, ) -> DefaultComponentCodec<C>
Wraps schema with the codec identity/version and restartability
declaration this component requires.
Sourcepub fn with_codec_upgrades(
self,
upgrades: Vec<CodecVersionUpgrade>,
) -> DefaultComponentCodec<C>
pub fn with_codec_upgrades( self, upgrades: Vec<CodecVersionUpgrade>, ) -> DefaultComponentCodec<C>
Declares the directed codec-version upgrades this codec can apply.
Sourcepub const fn with_sensitivity(
self,
sensitivity: StateSensitivity,
) -> DefaultComponentCodec<C>
pub const fn with_sensitivity( self, sensitivity: StateSensitivity, ) -> DefaultComponentCodec<C>
Declares this component’s state sensitivity.
Trait Implementations§
Source§impl<T, C> ComponentStateCodec<T> for DefaultComponentCodec<C>where
C: VersionedStateCodec<T>,
impl<T, C> ComponentStateCodec<T> for DefaultComponentCodec<C>where
C: VersionedStateCodec<T>,
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> for DefaultComponentCodec<C>where
C: VersionedStateCodec<T>,
impl<T, C> VersionedStateCodec<T> for DefaultComponentCodec<C>where
C: VersionedStateCodec<T>,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more