[−][src]Struct pyo3::Py
Safe wrapper around unsafe *mut ffi::PyObject pointer with specified type information.
Methods
impl<T> Py<T>[src]
impl<T> Py<T>pub unsafe fn from_owned_ptr(ptr: *mut PyObject) -> Py<T>[src]
pub unsafe fn from_owned_ptr(ptr: *mut PyObject) -> Py<T>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]
pub unsafe fn from_owned_ptr_or_panic(ptr: *mut PyObject) -> Py<T>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]
pub unsafe fn from_owned_ptr_or_err(
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]
pub unsafe fn from_borrowed_ptr(ptr: *mut PyObject) -> Py<T>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]
pub fn get_refcnt(&self) -> isizeGets the reference count of the ffi::PyObject pointer.
pub fn clone_ref(&self, _py: Python) -> Py<T>[src]
pub fn clone_ref(&self, _py: Python) -> Py<T>Clone self, Calls Py_INCREF() on the ptr.
impl<T> Py<T> where
T: PyTypeCreate, [src]
impl<T> Py<T> where
T: PyTypeCreate, pub fn new<F>(py: Python, f: F) -> PyResult<Py<T>> where
F: FnOnce() -> T,
T: PyTypeObject + PyTypeInfo, [src]
pub fn new<F>(py: Python, f: F) -> PyResult<Py<T>> where
F: FnOnce() -> T,
T: PyTypeObject + PyTypeInfo, Create new instance of T and move it under python management
Returns Py<T>.
pub fn new_ref<F>(py: Python, f: F) -> PyResult<&T> where
F: FnOnce() -> T,
T: PyTypeObject + PyTypeInfo, [src]
pub fn new_ref<F>(py: Python, f: F) -> PyResult<&T> where
F: FnOnce() -> T,
T: PyTypeObject + PyTypeInfo, Create new instance of T and move it under python management.
Returns references to T
pub fn new_mut<F>(py: Python, f: F) -> PyResult<&mut T> where
F: FnOnce() -> T,
T: PyTypeObject + PyTypeInfo, [src]
pub fn new_mut<F>(py: Python, f: F) -> PyResult<&mut T> where
F: FnOnce() -> T,
T: PyTypeObject + PyTypeInfo, 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]
impl<T> ToPyObject for Py<T>impl<T> IntoPyObject for Py<T>[src]
impl<T> IntoPyObject for Py<T>fn into_object(self, py: Python) -> PyObject[src]
fn into_object(self, py: Python) -> PyObjectConverts Py instance -> PyObject.
Consumes self without calling Py_DECREF()
impl IntoPyTuple for Py<PyTuple>[src]
impl IntoPyTuple for Py<PyTuple>fn into_tuple(self, _py: Python) -> Py<PyTuple>[src]
fn into_tuple(self, _py: Python) -> Py<PyTuple>impl<'a, T> FromPyObject<'a> for Py<T> where
T: ToPyPointer,
&'a T: 'a + FromPyObject<'a>, [src]
impl<'a, T> FromPyObject<'a> for Py<T> where
T: ToPyPointer,
&'a T: 'a + FromPyObject<'a>, fn extract(ob: &'a PyObjectRef) -> PyResult<Self>[src]
fn extract(ob: &'a PyObjectRef) -> PyResult<Self>Extracts Self from the source PyObject.
impl<T> AsPyRef<T> for Py<T> where
T: PyTypeInfo, [src]
impl<T> AsPyRef<T> for Py<T> where
T: PyTypeInfo, fn as_ref(&self, py: Python) -> &T[src]
fn as_ref(&self, py: Python) -> &Tfn as_mut(&mut self, py: Python) -> &mut T[src]
fn as_mut(&mut self, py: Python) -> &mut Tfn with<F, R>(&self, f: F) -> R where
F: FnOnce(Python, &T) -> R, [src]
fn with<F, R>(&self, f: F) -> R where
F: FnOnce(Python, &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, &mut T) -> R, [src]
fn with_mut<F, R>(&mut self, f: F) -> R where
F: FnOnce(Python, &mut 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, &T) -> R, [src]
fn into_py<F, R>(self, f: F) -> R where
Self: IntoPyPointer,
F: FnOnce(Python, &T) -> R, fn into_mut_py<F, R>(self, f: F) -> R where
Self: IntoPyPointer,
F: FnOnce(Python, &mut T) -> R, [src]
fn into_mut_py<F, R>(self, f: F) -> R where
Self: IntoPyPointer,
F: FnOnce(Python, &mut T) -> R, impl<T> ToPyPointer for Py<T>[src]
impl<T> ToPyPointer for Py<T>impl<T> IntoPyPointer for Py<T>[src]
impl<T> IntoPyPointer for Py<T>#[must_use]
fn into_ptr(self) -> *mut PyObject[src]
#[must_use]
fn into_ptr(self) -> *mut PyObjectGets the underlying FFI pointer, returns a owned pointer.
impl<T> PartialEq<Py<T>> for Py<T>[src]
impl<T> PartialEq<Py<T>> for Py<T>fn eq(&self, o: &Py<T>) -> bool[src]
fn eq(&self, o: &Py<T>) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl<T> From<Py<T>> for PyObject[src]
impl<T> From<Py<T>> for PyObjectimpl<'a, T> From<&'a T> for Py<T> where
T: ToPyPointer, [src]
impl<'a, T> From<&'a T> for Py<T> where
T: ToPyPointer, impl<'a, T> From<&'a mut T> for Py<T> where
T: ToPyPointer, [src]
impl<'a, T> From<&'a mut T> for Py<T> where
T: ToPyPointer, impl<T> Sync for Py<T>[src]
impl<T> Sync for Py<T>impl<T> Drop for Py<T>[src]
impl<T> Drop for Py<T>Dropping a Py instance decrements the reference count on the object by 1.
impl<T> Send for Py<T>[src]
impl<T> Send for Py<T>impl<T: Debug> Debug for Py<T>[src]
impl<T: Debug> Debug for Py<T>Blanket Implementations
impl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> From for T[src]
impl<T> From for Timpl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, 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]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut Timpl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId