pub struct PyCodecClassAdapter { /* private fields */ }Expand description
Wrapper around PyCodecClasses to use the DynCodecType API.
Implementations§
Source§impl PyCodecClassAdapter
impl PyCodecClassAdapter
Sourcepub fn from_codec_class(class: Bound<'_, PyCodecClass>) -> Result<Self, PyErr>
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.
Sourcepub fn as_codec_class<'py>(&self, py: Python<'py>) -> &Bound<'py, PyCodecClass>
pub fn as_codec_class<'py>(&self, py: Python<'py>) -> &Bound<'py, PyCodecClass>
Access the wrapped PyCodecClass to use its PyCodecClassMethods
API.
Sourcepub fn into_codec_class(self, py: Python<'_>) -> Bound<'_, PyCodecClass>
pub fn into_codec_class(self, py: Python<'_>) -> Bound<'_, PyCodecClass>
Unwrap the PyCodecClass to use its PyCodecClassMethods API.
Sourcepub fn with_downcast<T: DynCodecType, O: Ungil>(
py: Python<'_>,
class: &Bound<'_, PyCodecClass>,
with: impl Send + Ungil + for<'a> FnOnce(&'a T) -> O,
) -> Option<O>
pub fn with_downcast<T: DynCodecType, O: Ungil>( py: Python<'_>, class: &Bound<'_, PyCodecClass>, with: impl Send + Ungil + 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
impl DynCodecType for PyCodecClassAdapter
Source§type Codec = PyCodecAdapter
type Codec = PyCodecAdapter
Type of the instances of this codec type object.
Source§fn codec_config_schema(&self) -> Schema
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>
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 moreAuto Trait Implementations§
impl Freeze for PyCodecClassAdapter
impl !RefUnwindSafe for PyCodecClassAdapter
impl Send for PyCodecClassAdapter
impl Sync for PyCodecClassAdapter
impl Unpin for PyCodecClassAdapter
impl UnwindSafe for PyCodecClassAdapter
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