Trait IntoPyObjectExt
pub trait IntoPyObjectExt<'py>: IntoPyObject<'py> + Sealed {
// Provided methods
fn into_bound_py_any(
self,
py: Python<'py>,
) -> Result<Bound<'py, PyAny>, PyErr> ⓘ { ... }
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr> ⓘ { ... }
fn into_pyobject_or_pyerr(
self,
py: Python<'py>,
) -> Result<Self::Output, PyErr> ⓘ { ... }
}
Available on crate features
dep_pyo3
and std
only.Expand description
Convenience methods for common usages of IntoPyObject
. Every type that implements
IntoPyObject
also implements this trait.
These methods:
- Drop type information from the output, returning a
PyAny
object. - Always convert the
Error
type toPyErr
, which may incur a performance penalty but it more convenient in contexts where the?
operator would produce aPyErr
anyway.
Provided Methods§
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.
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr> ⓘ
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr> ⓘ
Converts self
into an owned Python object, dropping type information and unbinding it
from the 'py
lifetime.
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr> ⓘ
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr> ⓘ
Converts self
into a Python object.
This is equivalent to calling into_pyobject
followed
with .map_err(Into::into)
to convert the error type to PyErr
. This is helpful
for generic code which wants to make use of the ?
operator.
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.