[][src]Trait cpython::py_class::BaseObject

pub trait BaseObject: PythonObject {
    type InitType;
    pub fn size() -> usize;
pub unsafe fn alloc(
        py: Python<'_>,
        ty: &PyType,
        init_val: Self::InitType
    ) -> PyResult<PyObject>;
pub unsafe fn dealloc(py: Python<'_>, obj: *mut PyObject); }

A PythonObject that is usable as a base type with the py_class!() macro.

Associated Types

Loading content...

Required methods

pub fn size() -> usize[src]

Gets the size of the object, in bytes.

pub unsafe fn alloc(
    py: Python<'_>,
    ty: &PyType,
    init_val: Self::InitType
) -> PyResult<PyObject>
[src]

Allocates a new object (usually by calling ty->tp_alloc), and initializes it using init_val. ty must be derived from the Self type, and the resulting object must be of type ty.

pub unsafe fn dealloc(py: Python<'_>, obj: *mut PyObject)[src]

Calls the rust destructor for the object and frees the memory (usually by calling ptr->ob_type->tp_free). This function is used as tp_dealloc implementation.

Loading content...

Implementors

impl BaseObject for PyObject[src]

type InitType = ()

Loading content...