pub struct WasmCodec { /* private fields */ }
Expand description
Implementations§
Source§impl WasmCodec
Methods for implementing the Codec
trait
impl WasmCodec
Methods for implementing the Codec
trait
Sourcepub fn encode(
&self,
ctx: impl AsContextMut,
data: AnyCowArray<'_>,
) -> Result<Result<AnyArray, CodecError>, RuntimeError>
pub fn encode( &self, ctx: impl AsContextMut, data: AnyCowArray<'_>, ) -> Result<Result<AnyArray, CodecError>, RuntimeError>
Encodes the data
and returns the result.
The ctx
must refer to the same store in which the component was
instantiated.
§Errors
Errors with a
CodecError
if encoding the buffer fails.RuntimeError
if interacting with the component fails.
Sourcepub fn decode(
&self,
ctx: impl AsContextMut,
encoded: AnyCowArray<'_>,
) -> Result<Result<AnyArray, CodecError>, RuntimeError>
pub fn decode( &self, ctx: impl AsContextMut, encoded: AnyCowArray<'_>, ) -> Result<Result<AnyArray, CodecError>, RuntimeError>
Decodes the encoded
data and returns the result.
The ctx
must refer to the same store in which the component was
instantiated.
§Errors
Errors with a
CodecError
if decoding the buffer fails.RuntimeError
if interacting with the component fails.
Sourcepub fn decode_into(
&self,
ctx: impl AsContextMut,
encoded: AnyArrayView<'_>,
decoded: AnyArrayViewMut<'_>,
) -> Result<Result<(), CodecError>, RuntimeError>
pub fn decode_into( &self, ctx: impl AsContextMut, encoded: AnyArrayView<'_>, decoded: AnyArrayViewMut<'_>, ) -> Result<Result<(), CodecError>, RuntimeError>
Decodes the encoded
data and writes the result into the provided
decoded
output.
The output must have the correct type and shape.
The ctx
must refer to the same store in which the component was
instantiated.
§Errors
Errors with a
CodecError
if decoding the buffer fails.RuntimeError
if interacting with the component fails.
Source§impl WasmCodec
Methods for implementing the DynCodec
trait
impl WasmCodec
Methods for implementing the DynCodec
trait
Sourcepub fn ty(&self) -> WasmCodecComponent
pub fn ty(&self) -> WasmCodecComponent
Returns the component object for this codec.
Sourcepub fn get_config<S: Serializer>(
&self,
ctx: impl AsContextMut,
serializer: S,
) -> Result<S::Ok, S::Error>
pub fn get_config<S: Serializer>( &self, ctx: impl AsContextMut, serializer: S, ) -> Result<S::Ok, S::Error>
Serializes the configuration parameters for this codec.
The ctx
must refer to the same store in which the component was
instantiated.
§Errors
Errors if serializing the codec configuration or interacting with the component fails.
Source§impl WasmCodec
Methods for implementing the Clone
trait
impl WasmCodec
Methods for implementing the Clone
trait
Sourcepub fn try_clone(&self, ctx: impl AsContextMut) -> Result<Self, Error>
pub fn try_clone(&self, ctx: impl AsContextMut) -> Result<Self, Error>
Try cloning the codec by recreating it from its configuration.
The ctx
must refer to the same store in which the component was
instantiated.
§Errors
Errors if serializing the codec configuration, constructing the new codec, or interacting with the component fails.
Sourcepub fn try_clone_into(
&self,
ctx_from: impl AsContextMut,
ctx_into: impl AsContextMut,
) -> Result<Self, Error>
pub fn try_clone_into( &self, ctx_from: impl AsContextMut, ctx_into: impl AsContextMut, ) -> Result<Self, Error>
Try cloning the codec into a different context by recreating it from its configuration.
The ctx_from
must refer to the same store in which the component was
instantiated.
§Errors
Errors if serializing the codec configuration, constructing the new codec, or interacting with the component fails.
Auto Trait Implementations§
impl Freeze for WasmCodec
impl !RefUnwindSafe for WasmCodec
impl Send for WasmCodec
impl Sync for WasmCodec
impl Unpin for WasmCodec
impl !UnwindSafe for WasmCodec
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
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>
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>
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