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
config
uration.
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
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
)