Skip to main content

DefaultComponentCodec

Struct DefaultComponentCodec 

Source
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>

Source

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.

Source

pub fn with_codec_upgrades(self, upgrades: Vec<CodecVersionUpgrade>) -> Self

Declares the directed codec-version upgrades this codec can apply.

Source

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>

Source§

fn codec_id(&self) -> &CodecId

Returns the stable codec identifier.
Source§

fn codec_version(&self) -> CodecVersion

Returns the version emitted when encoding.
Source§

fn codec_upgrades(&self) -> &[CodecVersionUpgrade]

Declares the directed codec-version upgrades this codec can apply.
Source§

fn sensitivity(&self) -> StateSensitivity

Declares this component’s state sensitivity. Read more
Source§

fn restartability(&self) -> RestartabilityDeclaration

Declares whether this component can honestly claim restartability.
Source§

impl<T, C: VersionedStateCodec<T>> VersionedStateCodec<T> for DefaultComponentCodec<C>

Source§

fn schema_id(&self) -> &StateSchemaId

Returns the stable schema identifier.
Source§

fn current_version(&self) -> StateSchemaVersion

Returns the version emitted by encode.
Source§

fn upgrades(&self) -> &[StateSchemaUpgrade]

Declares the directed upgrades this codec can apply. Read more
Source§

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>

Decodes one JSON-object payload already at current_version. Read more

Auto 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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.