pub struct PySerde<T>(/* private fields */);Available on crate feature
unstable-serde only.Implementations§
Source§impl<'de, T> PySerde<T>where
T: Deserialize<'de>,
impl<'de, T> PySerde<T>where
T: Deserialize<'de>,
pub fn from_json_str<'py>(ob: &'de Bound<'py, PyString>) -> PyResult<Self>
pub fn from_json_bytes<'py>(ob: &'de Bound<'py, PyBytes>) -> PyResult<Self>
pub fn from_object<'py>(ob: &'de Bound<'py, PyAny>) -> PyResult<Self>
pub fn extract<'py>(ob: &'de Bound<'py, PyAny>) -> PyResult<Self>
Source§impl<T> PySerde<T>where
T: Serialize,
Benchmark(less is better):
impl<T> PySerde<T>where
T: Serialize,
Benchmark(less is better):
- Self::to_object : 0.9
- Self::to_json_str : 0.6
- json.loads(Self::to_json_str): 1.2
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for PySerde<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for PySerde<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'py, T> FromPyObject<'py> for PySerde<T>where
T: DeserializeOwned,
impl<'py, T> FromPyObject<'py> for PySerde<T>where
T: DeserializeOwned,
Source§fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self>
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self>
TODO: We have to use DeserializeOwned because in pyo3 v0.25 it cannot borrow data from the object.
We need to wait for pyo3::conversion::FromPyObjectBound.
See: https://github.com/PyO3/pyo3/pull/4390.
Use PySerde::extract as a workaround for now.
Source§impl<'py, T> IntoPyObject<'py> for &PySerde<T>where
T: Serialize,
impl<'py, T> IntoPyObject<'py> for &PySerde<T>where
T: Serialize,
Source§impl<'py, T> IntoPyObject<'py> for PySerde<T>where
T: Serialize,
impl<'py, T> IntoPyObject<'py> for PySerde<T>where
T: Serialize,
Source§impl<T: Ord> Ord for PySerde<T>
impl<T: Ord> Ord for PySerde<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for PySerde<T>
impl<T: PartialOrd> PartialOrd for PySerde<T>
impl<T: Copy> Copy for PySerde<T>
impl<T: Eq> Eq for PySerde<T>
impl<T> StructuralPartialEq for PySerde<T>
Auto Trait Implementations§
impl<T> Freeze for PySerde<T>where
T: Freeze,
impl<T> RefUnwindSafe for PySerde<T>where
T: RefUnwindSafe,
impl<T> Send for PySerde<T>where
T: Send,
impl<T> Sync for PySerde<T>where
T: Sync,
impl<T> Unpin for PySerde<T>where
T: Unpin,
impl<T> UnwindSafe for PySerde<T>where
T: UnwindSafe,
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§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
Source§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
Converts
self into an owned Python object, dropping type information.