Struct numcodecs_python::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,