Struct numcodecs_python::PyCodecAdapter
source · pub struct PyCodecAdapter { /* private fields */ }Implementations§
source§impl PyCodecAdapter
impl PyCodecAdapter
sourcepub fn from_registry_with_config<'de, D: Deserializer<'de>>(
config: D,
) -> Result<Self, D::Error>
pub fn from_registry_with_config<'de, D: Deserializer<'de>>( config: D, ) -> Result<Self, D::Error>
Instantiate a codec from the PyCodecRegistry with a serialized
configuration.
The config must include the id field with the
PyCodecClassMethods::codec_id.
§Errors
Errors if no codec with a matching id has been registered, or if
constructing the codec fails.
sourcepub fn as_codec<'py>(&self, py: Python<'py>) -> &Bound<'py, PyCodec>
pub fn as_codec<'py>(&self, py: Python<'py>) -> &Bound<'py, PyCodec>
Access the wrapped PyCodec to use its PyCodecMethods API.
sourcepub fn into_codec(self, py: Python<'_>) -> Bound<'_, PyCodec>
pub fn into_codec(self, py: Python<'_>) -> Bound<'_, PyCodec>
Unwrap the PyCodec to use its PyCodecMethods API.
sourcepub fn with_downcast<T: DynCodec, O>(
codec: &Bound<'_, PyCodec>,
with: impl for<'a> FnOnce(&'a T) -> O,
) -> Option<O>
pub fn with_downcast<T: DynCodec, O>( codec: &Bound<'_, PyCodec>, with: impl for<'a> FnOnce(&'a T) -> O, ) -> Option<O>
If codec represents an exported DynCodec T, i.e. its class was
initially created with crate::export_codec_class, the with closure
provides access to the instance of type T.
If codec is not an instance of T, the with closure is not run
and None is returned.
Trait Implementations§
source§impl Clone for PyCodecAdapter
impl Clone for PyCodecAdapter
source§impl Codec for PyCodecAdapter
impl Codec for PyCodecAdapter
source§fn encode(&self, data: AnyCowArray<'_>) -> Result<AnyArray, Self::Error>
fn encode(&self, data: AnyCowArray<'_>) -> Result<AnyArray, Self::Error>
Encodes the
data and returns the result. Read moresource§fn decode(&self, encoded: AnyCowArray<'_>) -> Result<AnyArray, Self::Error>
fn decode(&self, encoded: AnyCowArray<'_>) -> Result<AnyArray, Self::Error>
Decodes the
encoded data and returns the result. Read moresource§fn decode_into(
&self,
encoded: AnyArrayView<'_>,
decoded: AnyArrayViewMut<'_>,
) -> Result<(), Self::Error>
fn decode_into( &self, encoded: AnyArrayView<'_>, decoded: AnyArrayViewMut<'_>, ) -> Result<(), Self::Error>
source§impl DynCodec for PyCodecAdapter
impl DynCodec for PyCodecAdapter
§type Type = PyCodecClassAdapter
type Type = PyCodecClassAdapter
Type object type for this codec.
source§fn get_config<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>
fn get_config<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>
Serializes the configuration parameters for this codec. Read more
Auto Trait Implementations§
impl Freeze for PyCodecAdapter
impl !RefUnwindSafe for PyCodecAdapter
impl Send for PyCodecAdapter
impl Sync for PyCodecAdapter
impl Unpin for PyCodecAdapter
impl UnwindSafe for PyCodecAdapter
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)