[][src]Struct pyo3::type_object::PyRawObject

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:

use pyo3::prelude::*;

#[pyclass]
struct MyClass { }

#[pymethods]
impl MyClass {
   #[new]
   fn new(obj: &PyRawObject) {
       obj.init(MyClass { })
   }
}

Methods

impl PyRawObject[src]

#[must_use]
pub unsafe fn new(
    py: Python,
    tp_ptr: *mut PyTypeObject,
    curr_ptr: *mut PyTypeObject
) -> PyResult<PyRawObject>
[src]

#[must_use]
pub unsafe fn new_with_ptr(
    py: Python,
    ptr: *mut PyObject,
    tp_ptr: *mut PyTypeObject,
    curr_ptr: *mut PyTypeObject
) -> PyResult<PyRawObject>
[src]

pub fn init<T: PyTypeInfo>(&self, value: T)[src]

pub fn type_object(&self) -> &PyType[src]

Type object

Trait Implementations

impl IntoPyPointer for PyRawObject[src]

impl PyNativeType for PyRawObject[src]

fn py(&self) -> Python[src]

impl<T: PyTypeInfo> AsRef<T> for PyRawObject[src]

Auto Trait Implementations

impl !Send for PyRawObject

impl !Sync for PyRawObject

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]