Struct WasmCodecComponent

Source
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

Source

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

Source

pub fn codec_id(&self) -> &str

Codec identifier.

Source

pub fn codec_config_schema(&self) -> &Schema

JSON schema for the codec’s configuration.

Source

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§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.