[−][src]Struct pyo3::prelude::Py
Safe wrapper around unsafe *mut ffi::PyObject
pointer with specified type information.
Py<T>
is thread-safe, because any python related operations require a Python<'p> token.
Methods
impl<T> Py<T> where
T: PyTypeCreate + PyTypeObject,
[src]
T: PyTypeCreate + PyTypeObject,
pub fn new(py: Python, value: T) -> PyResult<Py<T>>
[src]
Create new instance of T and move it under python management
impl<T> Py<T>
[src]
pub unsafe fn from_owned_ptr(ptr: *mut PyObject) -> 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.
pub unsafe fn from_owned_ptr_or_panic(ptr: *mut PyObject) -> Py<T>
[src]
Creates a Py<T>
instance for the given FFI pointer.
Panics if the pointer is null
.
Undefined behavior if the pointer is invalid.
pub unsafe fn from_owned_ptr_or_err(
py: Python,
ptr: *mut PyObject
) -> PyResult<Py<T>>
[src]
py: Python,
ptr: *mut PyObject
) -> PyResult<Py<T>>
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.
pub unsafe fn from_borrowed_ptr(ptr: *mut PyObject) -> Py<T>
[src]
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.
pub fn get_refcnt(&self) -> isize
[src]
Gets the reference count of the ffi::PyObject pointer.
pub fn clone_ref(&self, _py: Python) -> Py<T>
[src]
Clone self, Calls Py_INCREF() on the ptr.
Trait Implementations
impl<T> ToPyObject for Py<T>
[src]
impl IntoPy<Py<PyTuple>> for NoArgs
[src]
Converts NoArgs
to an empty Python tuple.
impl IntoPy<Py<PyTuple>> for ()
[src]
Converts ()
to an empty Python tuple.
impl<'a> IntoPy<Py<PyTuple>> for &'a PyTuple
[src]
impl IntoPy<Py<PyTuple>> for Py<PyTuple>
[src]
impl<'a> IntoPy<Py<PyTuple>> for &'a str
[src]
impl<A: IntoPyObject> IntoPy<Py<PyTuple>> for (A,)
[src]
impl<A: IntoPyObject, B: IntoPyObject> IntoPy<Py<PyTuple>> for (A, B)
[src]
impl<A: IntoPyObject, B: IntoPyObject, C: IntoPyObject> IntoPy<Py<PyTuple>> for (A, B, C)
[src]
impl<A: IntoPyObject, B: IntoPyObject, C: IntoPyObject, D: IntoPyObject> IntoPy<Py<PyTuple>> for (A, B, C, D)
[src]
impl<A: IntoPyObject, B: IntoPyObject, C: IntoPyObject, D: IntoPyObject, E: IntoPyObject> IntoPy<Py<PyTuple>> for (A, B, C, D, E)
[src]
impl<A: IntoPyObject, B: IntoPyObject, C: IntoPyObject, D: IntoPyObject, E: IntoPyObject, F: IntoPyObject> IntoPy<Py<PyTuple>> for (A, B, C, D, E, F)
[src]
impl<A: IntoPyObject, B: IntoPyObject, C: IntoPyObject, D: IntoPyObject, E: IntoPyObject, F: IntoPyObject, G: IntoPyObject> IntoPy<Py<PyTuple>> for (A, B, C, D, E, F, G)
[src]
impl<A: IntoPyObject, B: IntoPyObject, C: IntoPyObject, D: IntoPyObject, E: IntoPyObject, F: IntoPyObject, G: IntoPyObject, H: IntoPyObject> IntoPy<Py<PyTuple>> for (A, B, C, D, E, F, G, H)
[src]
impl<A: IntoPyObject, B: IntoPyObject, C: IntoPyObject, D: IntoPyObject, E: IntoPyObject, F: IntoPyObject, G: IntoPyObject, H: IntoPyObject, I: IntoPyObject> IntoPy<Py<PyTuple>> for (A, B, C, D, E, F, G, H, I)
[src]
impl<T> IntoPyObject for Py<T>
[src]
fn into_object(self, py: Python) -> PyObject
[src]
Converts Py
instance -> PyObject.
Consumes self
without calling Py_DECREF()
impl<'a, T> FromPyObject<'a> for Py<T> where
T: ToPyPointer,
&'a T: 'a + FromPyObject<'a>,
[src]
T: ToPyPointer,
&'a T: 'a + FromPyObject<'a>,
fn extract(ob: &'a PyObjectRef) -> PyResult<Self>
[src]
Extracts Self
from the source PyObject
.
impl<T> AsPyRef<T> for Py<T> where
T: PyTypeInfo,
[src]
T: PyTypeInfo,
fn as_ref(&self, py: Python) -> PyRef<T>
[src]
fn as_mut(&mut self, py: Python) -> PyRefMut<T>
[src]
fn with<F, R>(&self, f: F) -> R where
F: FnOnce(Python, PyRef<T>) -> R,
[src]
F: FnOnce(Python, PyRef<T>) -> R,
Acquire python gil and call closure with object reference.
fn with_mut<F, R>(&mut self, f: F) -> R where
F: FnOnce(Python, PyRefMut<T>) -> R,
[src]
F: FnOnce(Python, PyRefMut<T>) -> R,
Acquire python gil and call closure with mutable object reference.
fn into_py<F, R>(self, f: F) -> R where
Self: IntoPyPointer,
F: FnOnce(Python, PyRef<T>) -> R,
[src]
Self: IntoPyPointer,
F: FnOnce(Python, PyRef<T>) -> R,
fn into_mut_py<F, R>(self, f: F) -> R where
Self: IntoPyPointer,
F: FnOnce(Python, PyRefMut<T>) -> R,
[src]
Self: IntoPyPointer,
F: FnOnce(Python, PyRefMut<T>) -> R,
impl<T> ToPyPointer for Py<T>
[src]
impl<T> IntoPyPointer for Py<T>
[src]
#[must_use]
fn into_ptr(self) -> *mut PyObject
[src]
Gets the underlying FFI pointer, returns a owned pointer.
impl<T> From<Py<T>> for PyObject
[src]
impl<'a, T> From<PyRef<'a, T>> for Py<T> where
T: PyTypeInfo,
[src]
T: PyTypeInfo,
impl<'a, T> From<PyRefMut<'a, T>> for Py<T> where
T: PyTypeInfo,
[src]
T: PyTypeInfo,
impl<T> PartialEq<Py<T>> for Py<T>
[src]
fn eq(&self, o: &Py<T>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T> Send for Py<T>
[src]
impl<T> Sync for Py<T>
[src]
impl<T> Drop for Py<T>
[src]
Dropping a Py
instance decrements the reference count on the object by 1.
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]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,