Struct pyo3::typeob::PyRawObject
[−]
[src]
pub struct PyRawObject { /* fields omitted */ }
Special object that is used for python object creation.
pyo3
library automatically creates this object for class __new__
method.
Behavior is undefined if constructor of custom class does not initialze
instance of PyRawObject
with rust value with init
method.
Calling of __new__
method of base class is developer's responsibility.
Example of custom class implementation with __new__
method:
ⓘThis example is not tested
#[py::class] struct MyClass { token: PyToken } #[py::methods] impl MyClass { #[new] fn __new__(obj: &PyRawObject) -> PyResult<()> { obj.init(|token| MyClass{token| token}) MyClass::BaseType::__new__(obj) } }
Methods
impl PyRawObject
[src]
pub unsafe fn new(
py: Python,
tp_ptr: *mut PyTypeObject,
curr_ptr: *mut PyTypeObject
) -> PyResult<PyRawObject>
[src]
py: Python,
tp_ptr: *mut PyTypeObject,
curr_ptr: *mut PyTypeObject
) -> PyResult<PyRawObject>
pub unsafe fn new_with_ptr(
py: Python,
ptr: *mut PyObject,
tp_ptr: *mut PyTypeObject,
curr_ptr: *mut PyTypeObject
) -> PyResult<PyRawObject>
[src]
py: Python,
ptr: *mut PyObject,
tp_ptr: *mut PyTypeObject,
curr_ptr: *mut PyTypeObject
) -> PyResult<PyRawObject>
pub fn init<T, F>(&self, f: F) -> PyResult<()> where
F: FnOnce(PyToken) -> T,
T: PyTypeInfo,
[src]
F: FnOnce(PyToken) -> T,
T: PyTypeInfo,
pub fn type_object(&self) -> &PyType
[src]
Type object
pub fn as_ref<T: PyTypeInfo>(&self) -> &T
[src]
Return reference to object.
Trait Implementations
impl IntoPyPointer for PyRawObject
[src]
fn into_ptr(self) -> *mut PyObject
[src]
Retrieves the underlying FFI pointer. Whether pointer owned or borrowed depends on implementation. Read more