[][src]Trait pyo3::PyTryFrom

pub trait PyTryFrom: Sized {
    fn try_from(value: &PyObjectRef) -> Result<&Self, PyDowncastError>;
fn try_from_exact(value: &PyObjectRef) -> Result<&Self, PyDowncastError>;
fn try_from_mut(value: &PyObjectRef) -> Result<&mut Self, PyDowncastError>;
fn try_from_mut_exact(
        value: &PyObjectRef
    ) -> Result<&mut Self, PyDowncastError>;
unsafe fn try_from_unchecked(value: &PyObjectRef) -> &Self;
unsafe fn try_from_mut_unchecked(value: &PyObjectRef) -> &mut Self; }

Trait implemented by Python object types that allow a checked downcast. This trait is similar to std::convert::TryFrom

Required methods

fn try_from(value: &PyObjectRef) -> Result<&Self, PyDowncastError>

Cast from a concrete Python object type to PyObject.

fn try_from_exact(value: &PyObjectRef) -> Result<&Self, PyDowncastError>

Cast from a concrete Python object type to PyObject. With exact type check.

fn try_from_mut(value: &PyObjectRef) -> Result<&mut Self, PyDowncastError>

Cast from a concrete Python object type to PyObject.

fn try_from_mut_exact(value: &PyObjectRef) -> Result<&mut Self, PyDowncastError>

Cast from a concrete Python object type to PyObject. With exact type check.

unsafe fn try_from_unchecked(value: &PyObjectRef) -> &Self

Cast a PyObjectRef to a specific type of PyObject. The caller must have already verified the reference is for this type.

unsafe fn try_from_mut_unchecked(value: &PyObjectRef) -> &mut Self

Cast a PyObjectRef to a specific type of PyObject. The caller must have already verified the reference is for this type.

Loading content...

Implementors

Loading content...