Struct pyo3::PyObject [−][src]
pub struct PyObject(_);
Safe wrapper around unsafe *mut ffi::PyObject
pointer.
Methods
impl PyObject
[src]
impl PyObject
pub unsafe fn from_owned_ptr(_py: Python, ptr: *mut PyObject) -> PyObject
[src]
pub unsafe fn from_owned_ptr(_py: Python, ptr: *mut PyObject) -> PyObject
Creates a PyObject
instance for the given FFI pointer.
This moves ownership over the pointer into the PyObject
.
Undefined behavior if the pointer is NULL or invalid.
pub unsafe fn from_owned_ptr_or_panic(
py: Python,
ptr: *mut PyObject
) -> PyObject
[src]
pub unsafe fn from_owned_ptr_or_panic(
py: Python,
ptr: *mut PyObject
) -> PyObject
Creates a PyObject
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<PyObject>
[src]
pub unsafe fn from_owned_ptr_or_err(
py: Python,
ptr: *mut PyObject
) -> PyResult<PyObject>
Construct PyObject
from the result of a Python FFI call that
returns a new reference (owned pointer).
Returns Err(PyErr)
if the pointer is null
.
pub unsafe fn from_owned_ptr_or_opt(
py: Python,
ptr: *mut PyObject
) -> Option<PyObject>
[src]
pub unsafe fn from_owned_ptr_or_opt(
py: Python,
ptr: *mut PyObject
) -> Option<PyObject>
Construct PyObject
from the result of a Python FFI call that
returns a new reference (owned pointer).
Returns None
if the pointer is null
.
pub unsafe fn from_borrowed_ptr(_py: Python, ptr: *mut PyObject) -> PyObject
[src]
pub unsafe fn from_borrowed_ptr(_py: Python, ptr: *mut PyObject) -> PyObject
Creates a PyObject
instance for the given Python FFI pointer.
Calls Py_INCREF() on the ptr.
Undefined behavior if the pointer is NULL or invalid.
pub unsafe fn from_borrowed_ptr_or_err(
py: Python,
ptr: *mut PyObject
) -> PyResult<PyObject>
[src]
pub unsafe fn from_borrowed_ptr_or_err(
py: Python,
ptr: *mut PyObject
) -> PyResult<PyObject>
Creates a PyObject
instance for the given Python FFI pointer.
Calls Py_INCREF() on the ptr.
Returns Err(PyErr)
if the pointer is null
.
pub unsafe fn from_borrowed_ptr_or_opt(
py: Python,
ptr: *mut PyObject
) -> Option<PyObject>
[src]
pub unsafe fn from_borrowed_ptr_or_opt(
py: Python,
ptr: *mut PyObject
) -> Option<PyObject>
Creates a PyObject
instance for the given Python FFI pointer.
Calls Py_INCREF() on the ptr.
Returns None
if the pointer is null
.
pub fn get_refcnt(&self) -> isize
[src]
pub fn get_refcnt(&self) -> isize
Gets the reference count of the ffi::PyObject pointer.
pub fn clone_ref(&self, py: Python) -> Self
[src]
pub fn clone_ref(&self, py: Python) -> Self
Clone self, Calls Py_INCREF() on the ptr.
pub fn is_none(&self) -> bool
[src]
pub fn is_none(&self) -> bool
Returns whether the object is considered to be None. This is equivalent to the Python expression: 'is None'
pub fn is_true(&self, py: Python) -> PyResult<bool>
[src]
pub fn is_true(&self, py: Python) -> PyResult<bool>
Returns whether the object is considered to be true. This is equivalent to the Python expression: 'not not self'
pub fn cast_as<D>(&self, py: Python) -> Result<&D, <D as PyTryFrom>::Error> where
D: PyTryFrom<Error = PyDowncastError>,
[src]
pub fn cast_as<D>(&self, py: Python) -> Result<&D, <D as PyTryFrom>::Error> where
D: PyTryFrom<Error = PyDowncastError>,
Casts the PyObject to a concrete Python object type.
pub fn extract<'p, D>(&'p self, py: Python) -> PyResult<D> where
D: FromPyObject<'p>,
[src]
pub fn extract<'p, D>(&'p self, py: Python) -> PyResult<D> where
D: FromPyObject<'p>,
Extracts some type from the Python object.
This is a wrapper function around FromPyObject::extract()
.
pub fn getattr<N>(&self, py: Python, attr_name: N) -> PyResult<PyObject> where
N: ToPyObject,
[src]
pub fn getattr<N>(&self, py: Python, attr_name: N) -> PyResult<PyObject> where
N: ToPyObject,
Retrieves an attribute value. This is equivalent to the Python expression 'self.attr_name'.
pub fn call<A, K>(&self, py: Python, args: A, kwargs: K) -> PyResult<PyObject> where
A: IntoPyTuple,
K: IntoPyDictPointer,
[src]
pub fn call<A, K>(&self, py: Python, args: A, kwargs: K) -> PyResult<PyObject> where
A: IntoPyTuple,
K: IntoPyDictPointer,
Calls the object. This is equivalent to the Python expression: 'self(*args, **kwargs)'
pub fn call0(&self, py: Python) -> PyResult<PyObject>
[src]
pub fn call0(&self, py: Python) -> PyResult<PyObject>
Calls the object without arguments. This is equivalent to the Python expression: 'self()'
pub fn call1<A>(&self, py: Python, args: A) -> PyResult<PyObject> where
A: IntoPyTuple,
[src]
pub fn call1<A>(&self, py: Python, args: A) -> PyResult<PyObject> where
A: IntoPyTuple,
Calls the object. This is equivalent to the Python expression: 'self(*args)'
pub fn call_method<A, K>(
&self,
py: Python,
name: &str,
args: A,
kwargs: K
) -> PyResult<PyObject> where
A: IntoPyTuple,
K: IntoPyDictPointer,
[src]
pub fn call_method<A, K>(
&self,
py: Python,
name: &str,
args: A,
kwargs: K
) -> PyResult<PyObject> where
A: IntoPyTuple,
K: IntoPyDictPointer,
Calls a method on the object. This is equivalent to the Python expression: 'self.name(*args, **kwargs)'
pub fn call_method0(&self, py: Python, name: &str) -> PyResult<PyObject>
[src]
pub fn call_method0(&self, py: Python, name: &str) -> PyResult<PyObject>
Calls a method on the object. This is equivalent to the Python expression: 'self.name()'
pub fn call_method1<A>(
&self,
py: Python,
name: &str,
args: A
) -> PyResult<PyObject> where
A: IntoPyTuple,
[src]
pub fn call_method1<A>(
&self,
py: Python,
name: &str,
args: A
) -> PyResult<PyObject> where
A: IntoPyTuple,
Calls a method on the object. This is equivalent to the Python expression: 'self.name(*args)'
Trait Implementations
impl<T> From<Py<T>> for PyObject
[src]
impl<T> From<Py<T>> for PyObject
impl<'a, T> From<&'a T> for PyObject where
T: ToPyPointer,
[src]
impl<'a, T> From<&'a T> for PyObject where
T: ToPyPointer,
impl<'a, T> From<&'a mut T> for PyObject where
T: ToPyPointer,
[src]
impl<'a, T> From<&'a mut T> for PyObject where
T: ToPyPointer,
impl Debug for PyObject
[src]
impl Debug for PyObject
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Send for PyObject
[src]
impl Send for PyObject
impl Sync for PyObject
[src]
impl Sync for PyObject
impl AsPyRef<PyObjectRef> for PyObject
[src]
impl AsPyRef<PyObjectRef> for PyObject
fn as_ref(&self, _py: Python) -> &PyObjectRef
[src]
fn as_ref(&self, _py: Python) -> &PyObjectRef
Return reference to object.
fn as_mut(&self, _py: Python) -> &mut PyObjectRef
[src]
fn as_mut(&self, _py: Python) -> &mut PyObjectRef
Return mutable reference to object.
fn 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>(&self, f: F) -> R where
F: FnOnce(Python, &mut T) -> R,
[src]
fn with_mut<F, R>(&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 ToPyObject for PyObject
[src]
impl ToPyObject for PyObject
impl ToBorrowedObject for PyObject
[src]
impl ToBorrowedObject for PyObject
fn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R,
[src]
fn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R,
Converts self into a Python object and calls the specified closure on the native FFI pointer underlying the Python object. Read more
impl ToPyPointer for PyObject
[src]
impl ToPyPointer for PyObject
impl<'a> ToPyPointer for &'a PyObject
[src]
impl<'a> ToPyPointer for &'a PyObject
impl IntoPyPointer for PyObject
[src]
impl IntoPyPointer for PyObject
impl PartialEq for PyObject
[src]
impl PartialEq for PyObject
fn eq(&self, o: &PyObject) -> bool
[src]
fn eq(&self, o: &PyObject) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl IntoPyObject for PyObject
[src]
impl IntoPyObject for PyObject
fn into_object(self, _py: Python) -> PyObject
[src]
fn into_object(self, _py: Python) -> PyObject
Converts self into a Python object. (Consumes self)
impl<'a> FromPyObject<'a> for PyObject
[src]
impl<'a> FromPyObject<'a> for PyObject
fn extract(ob: &'a PyObjectRef) -> PyResult<Self>
[src]
fn extract(ob: &'a PyObjectRef) -> PyResult<Self>
Extracts Self
from the source PyObject
.
impl Drop for PyObject
[src]
impl Drop for PyObject
Dropping a PyObject
instance decrements the reference count on the object by 1.