Trait pyo3::prelude::PyTryFrom [−][src]
pub trait PyTryFrom: Sized { type Error; fn try_from(value: &PyObjectRef) -> Result<&Self, Self::Error>; fn try_from_exact(value: &PyObjectRef) -> Result<&Self, Self::Error>; fn try_from_mut(value: &PyObjectRef) -> Result<&mut Self, Self::Error>; fn try_from_mut_exact(value: &PyObjectRef) -> Result<&mut Self, Self::Error>; }
Trait implemented by Python object types that allow a checked downcast.
This trait is similar to std::convert::TryFrom
Associated Types
type Error
The type returned in the event of a conversion error.
Required Methods
fn try_from(value: &PyObjectRef) -> Result<&Self, Self::Error>
Cast from a concrete Python object type to PyObject.
fn try_from_exact(value: &PyObjectRef) -> Result<&Self, Self::Error>
Cast from a concrete Python object type to PyObject. With exact type check.
fn try_from_mut(value: &PyObjectRef) -> Result<&mut Self, Self::Error>
Cast from a concrete Python object type to PyObject.
fn try_from_mut_exact(value: &PyObjectRef) -> Result<&mut Self, Self::Error>
Cast from a concrete Python object type to PyObject. With exact type check.
Implementors
impl<T> PyTryFrom for T where
T: PyTypeInfo, type Error = PyDowncastError;impl PyTryFrom for PySequence type Error = PyDowncastError;