Struct cpython::PyRustObject
[−]
[src]
pub struct PyRustObject<T, B = PyObject> where T: 'static + Send, B: PythonBaseObject { // some fields omitted }
A Python object that contains a rust value of type T,
and is derived from base class B.
Note that this type effectively acts like Rc<T>,
except that the reference counting is done by the Python runtime.
Methods
impl<T, B> PyRustObject<T, B> where T: 'static + Send, B: PythonBaseObject[src]
fn as_base(&self) -> &B
Gets a reference to this object, but of the base class type.
fn into_base(self) -> B
Gets a reference to this object, but of the base class type.
fn get<'a>(&'a self, _py: Python<'a>) -> &'a T
Gets a reference to the rust value stored in this Python object.
Trait Implementations
impl<T, B> ToPyObject for PyRustObject<T, B> where T: 'static + Send, B: PythonBaseObject[src]
type ObjectType = PyObject
fn to_py_object(&self, py: Python) -> PyObject
Converts self into a Python object.
fn into_py_object(self, _py: Python) -> PyObject
Converts self into a Python object. Read more
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<T, B> PythonObject for PyRustObject<T, B> where T: 'static + Send, B: PythonBaseObject[src]
fn as_object(&self) -> &PyObject
Casts the Python object to PyObject.
fn into_object(self) -> PyObject
Casts the Python object to PyObject.
unsafe fn unchecked_downcast_from(obj: PyObject) -> Self
Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
unsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a Self
Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.