numcodecs_python

Struct PyCodecClassAdapter

Source
pub struct PyCodecClassAdapter { /* private fields */ }
Expand description

Wrapper around PyCodecClasses to use the DynCodecType API.

Implementations§

Source§

impl PyCodecClassAdapter

Source

pub fn from_codec_class(class: Bound<'_, PyCodecClass>) -> Result<Self, PyErr>

Wraps a PyCodecClass to use the DynCodecType API.

§Errors

Errors if the codec class does not provide an identifier.

Source

pub fn as_codec_class<'py>(&self, py: Python<'py>) -> &Bound<'py, PyCodecClass>

Access the wrapped PyCodecClass to use its PyCodecClassMethods API.

Source

pub fn into_codec_class(self, py: Python<'_>) -> Bound<'_, PyCodecClass>

Unwrap the PyCodecClass to use its PyCodecClassMethods API.

Source

pub fn with_downcast<T: DynCodecType, O>( class: &Bound<'_, PyCodecClass>, with: impl for<'a> FnOnce(&'a T) -> O, ) -> Option<O>

If class represents an exported DynCodecType T, i.e. it was initially created with crate::export_codec_class, the with closure provides access to the instance of type T.

If class is not an instance of T, the with closure is not run and None is returned.

Trait Implementations§

Source§

impl DynCodecType for PyCodecClassAdapter

Source§

type Codec = PyCodecAdapter

Type of the instances of this codec type object.
Source§

fn codec_id(&self) -> &str

Codec identifier.
Source§

fn codec_config_schema(&self) -> Schema

JSON schema for the codec’s configuration.
Source§

fn codec_from_config<'de, D: Deserializer<'de>>( &self, config: D, ) -> Result<Self::Codec, D::Error>

Instantiate a codec of this type from a serialized configuration. Read more

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

impl<T> Ungil for T
where T: Send,