[][src]Struct pyo3::Py

#[repr(transparent)]
pub struct Py<T>(_, _);

Safe wrapper around unsafe *mut ffi::PyObject pointer with specified type information.

Methods

impl<T> Py<T>
[src]

Creates a Py<T> instance for the given FFI pointer. This moves ownership over the pointer into the Py<T>. Undefined behavior if the pointer is NULL or invalid.

Creates a Py<T> instance for the given FFI pointer. Panics if the pointer is null. Undefined behavior if the pointer is invalid.

Construct Py<T> from the result of a Python FFI call that returns a new reference (owned pointer). Returns Err(PyErr) if the pointer is null. Unsafe because the pointer might be invalid.

Creates a Py<T> instance for the given Python FFI pointer. Calls Py_INCREF() on the ptr. Undefined behavior if the pointer is NULL or invalid.

Gets the reference count of the ffi::PyObject pointer.

Clone self, Calls Py_INCREF() on the ptr.

impl<T> Py<T> where
    T: PyTypeCreate
[src]

Create new instance of T and move it under python management Returns Py<T>.

Create new instance of T and move it under python management. Returns references to T

Create new instance of T and move it under python management. Returns mutable references to T

Trait Implementations

impl<T> ToPyObject for Py<T>
[src]

Converts Py instance -> PyObject.

impl<T> IntoPyObject for Py<T>
[src]

Converts Py instance -> PyObject. Consumes self without calling Py_DECREF()

impl IntoPyTuple for Py<PyTuple>
[src]

impl<'a, T> FromPyObject<'a> for Py<T> where
    T: ToPyPointer,
    &'a T: 'a + FromPyObject<'a>, 
[src]

Extracts Self from the source PyObject.

impl<T> AsPyRef<T> for Py<T> where
    T: PyTypeInfo
[src]

Acquire python gil and call closure with object reference.

Acquire python gil and call closure with mutable object reference.

impl<T> ToPyPointer for Py<T>
[src]

Gets the underlying FFI pointer, returns a borrowed pointer.

impl<T> IntoPyPointer for Py<T>
[src]

Gets the underlying FFI pointer, returns a owned pointer.

impl<T> From<Py<T>> for PyObject
[src]

impl<'a, T> From<&'a T> for Py<T> where
    T: ToPyPointer
[src]

impl<'a, T> From<&'a mut T> for Py<T> where
    T: ToPyPointer
[src]

impl<T> Drop for Py<T>
[src]

Dropping a Py instance decrements the reference count on the object by 1.

impl<T> Sync for Py<T>
[src]

impl<T> PartialEq<Py<T>> for Py<T>
[src]

This method tests for !=.

impl<T> Send for Py<T>
[src]

impl<T: Debug> Debug for Py<T>
[src]

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]