pub trait PythonObjectWithCheckedDowncast: PythonObject {
// Required methods
fn downcast_from(
py: Python<'_>,
obj: PyObject,
) -> Result<Self, PythonObjectDowncastError<'_>>;
fn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject,
) -> Result<&'a Self, PythonObjectDowncastError<'p>>;
}
Expand description
Trait implemented by Python object types that allow a checked downcast.
Required Methods§
Sourcefn downcast_from(
py: Python<'_>,
obj: PyObject,
) -> Result<Self, PythonObjectDowncastError<'_>>
fn downcast_from( py: Python<'_>, obj: PyObject, ) -> Result<Self, PythonObjectDowncastError<'_>>
Cast from PyObject to a concrete Python object type.
Sourcefn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject,
) -> Result<&'a Self, PythonObjectDowncastError<'p>>
fn downcast_borrow_from<'a, 'p>( py: Python<'p>, obj: &'a PyObject, ) -> Result<&'a Self, PythonObjectDowncastError<'p>>
Cast from PyObject to a concrete Python object type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.