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.
Source§impl WasmCodec
Methods for implementing the Drop
trait
impl WasmCodec
Methods for implementing the Drop
trait
Sourcepub fn try_drop(&self, ctx: impl AsContextMut) -> Result<(), RuntimeError>
pub fn try_drop(&self, ctx: impl AsContextMut) -> Result<(), RuntimeError>
Try dropping the codec.
The ctx
must refer to the same store in which the component was
instantiated.
§Errors
Errors if the codec’s resource is borrowed or has already been dropped.