pub unsafe trait FromPyPointer<'p>: Sized {
    // Required methods
    unsafe fn from_owned_ptr_or_opt(
        py: Python<'p>,
        ptr: *mut PyObject
    ) -> Option<&'p Self>;
    unsafe fn from_borrowed_ptr_or_opt(
        py: Python<'p>,
        ptr: *mut PyObject
    ) -> Option<&'p Self>;

    // Provided methods
    unsafe fn from_owned_ptr_or_panic(
        py: Python<'p>,
        ptr: *mut PyObject
    ) -> &'p Self { ... }
    unsafe fn from_owned_ptr(py: Python<'p>, ptr: *mut PyObject) -> &'p Self { ... }
    unsafe fn from_owned_ptr_or_err(
        py: Python<'p>,
        ptr: *mut PyObject
    ) -> PyResult<&'p Self> { ... }
    unsafe fn from_borrowed_ptr_or_panic(
        py: Python<'p>,
        ptr: *mut PyObject
    ) -> &'p Self { ... }
    unsafe fn from_borrowed_ptr(py: Python<'p>, ptr: *mut PyObject) -> &'p Self { ... }
    unsafe fn from_borrowed_ptr_or_err(
        py: Python<'p>,
        ptr: *mut PyObject
    ) -> PyResult<&'p Self> { ... }
}
👎Deprecated since 0.21.0
Expand description

Raw level conversion between *mut ffi::PyObject and PyO3 types.

§Safety

See safety notes on individual functions.

Required Methods§

source

unsafe fn from_owned_ptr_or_opt( py: Python<'p>, ptr: *mut PyObject ) -> Option<&'p Self>

👎Deprecated since 0.21.0: use Py::from_owned_ptr_or_opt(py, ptr) or Bound::from_owned_ptr_or_opt(py, ptr) instead

Convert from an arbitrary PyObject.

§Safety

Implementations must ensure the object does not get freed during 'p and ensure that ptr is of the correct type. Note that it must be safe to decrement the reference count of ptr.

source

unsafe fn from_borrowed_ptr_or_opt( py: Python<'p>, ptr: *mut PyObject ) -> Option<&'p Self>

👎Deprecated since 0.21.0: use Py::from_borrowed_ptr_or_opt(py, ptr) or Bound::from_borrowed_ptr_or_opt(py, ptr) instead

Convert from an arbitrary borrowed PyObject.

§Safety

Implementations must ensure the object does not get freed during 'p and avoid type confusion.

Provided Methods§

source

unsafe fn from_owned_ptr_or_panic( py: Python<'p>, ptr: *mut PyObject ) -> &'p Self

👎Deprecated since 0.21.0: use Py::from_owned_ptr(py, ptr) or Bound::from_owned_ptr(py, ptr) instead

Convert from an arbitrary PyObject or panic.

§Safety

Relies on from_owned_ptr_or_opt.

source

unsafe fn from_owned_ptr(py: Python<'p>, ptr: *mut PyObject) -> &'p Self

👎Deprecated since 0.21.0: use Py::from_owned_ptr(py, ptr) or Bound::from_owned_ptr(py, ptr) instead

Convert from an arbitrary PyObject or panic.

§Safety

Relies on from_owned_ptr_or_opt.

source

unsafe fn from_owned_ptr_or_err( py: Python<'p>, ptr: *mut PyObject ) -> PyResult<&'p Self>

👎Deprecated since 0.21.0: use Py::from_owned_ptr_or_err(py, ptr) or Bound::from_owned_ptr_or_err(py, ptr) instead

Convert from an arbitrary PyObject.

§Safety

Relies on from_owned_ptr_or_opt.

source

unsafe fn from_borrowed_ptr_or_panic( py: Python<'p>, ptr: *mut PyObject ) -> &'p Self

👎Deprecated since 0.21.0: use Py::from_borrowed_ptr(py, ptr) or Bound::from_borrowed_ptr(py, ptr) instead

Convert from an arbitrary borrowed PyObject.

§Safety

Relies on unsafe fn from_borrowed_ptr_or_opt.

source

unsafe fn from_borrowed_ptr(py: Python<'p>, ptr: *mut PyObject) -> &'p Self

👎Deprecated since 0.21.0: use Py::from_borrowed_ptr(py, ptr) or Bound::from_borrowed_ptr(py, ptr) instead

Convert from an arbitrary borrowed PyObject.

§Safety

Relies on unsafe fn from_borrowed_ptr_or_opt.

source

unsafe fn from_borrowed_ptr_or_err( py: Python<'p>, ptr: *mut PyObject ) -> PyResult<&'p Self>

👎Deprecated since 0.21.0: use Py::from_borrowed_ptr_or_err(py, ptr) or Bound::from_borrowed_ptr_or_err(py, ptr) instead

Convert from an arbitrary borrowed PyObject.

§Safety

Relies on unsafe fn from_borrowed_ptr_or_opt.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'p, T> FromPyPointer<'p> for T
where T: 'p + PyNativeType,