pub struct WasmCodecComponent { /* private fields */ }Expand description
WebAssembly component that exports the numcodecs:abc/codec interface.
WasmCodecComponent does not implement the
DynCodecType trait itself so that it can expose
un-opinionated bindings. However, it provides methods with that can be used
to implement the trait on a wrapper.
Implementations§
Source§impl WasmCodecComponent
impl WasmCodecComponent
Sourcepub fn new(
ctx: impl AsContextMut,
instance: Instance,
) -> Result<Self, RuntimeError>
pub fn new( ctx: impl AsContextMut, instance: Instance, ) -> Result<Self, RuntimeError>
Import the numcodecs:abc/codec interface from a WebAssembly component
instance.
The ctx must refer to the same store in which the instance was
instantiated.
§Warning
The WasmCodecComponent does not own the provided instance and
never calls [Instance::drop]. It is the responsibility of the code
creating the WasmCodecComponent to destroy the instance after the
component, and all codecs created from it, have been destroyed.
§Errors
Errors if the instance does not export the numcodecs:abc/codec
interface or if interacting with the component fails.
Source§impl WasmCodecComponent
Methods for implementing the DynCodecType trait
impl WasmCodecComponent
Methods for implementing the DynCodecType trait
Sourcepub fn codec_config_schema(&self) -> &Schema
pub fn codec_config_schema(&self) -> &Schema
JSON schema for the codec’s configuration.
Sourcepub fn codec_from_config<'de, D: Deserializer<'de>>(
&self,
ctx: impl AsContextMut,
config: D,
) -> Result<WasmCodec, D::Error>
pub fn codec_from_config<'de, D: Deserializer<'de>>( &self, ctx: impl AsContextMut, config: D, ) -> Result<WasmCodec, D::Error>
Instantiate a codec of this type from a serialized configuration.
The config must not contain an id field. If the config may
contain one, use the
codec_from_config_with_id
helper function.
The config must be compatible with JSON encoding.
§Errors
Errors if constructing the codec or interacting with the component fails.
Auto Trait Implementations§
impl Freeze for WasmCodecComponent
impl !RefUnwindSafe for WasmCodecComponent
impl Send for WasmCodecComponent
impl Sync for WasmCodecComponent
impl Unpin for WasmCodecComponent
impl !UnwindSafe for WasmCodecComponent
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