MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / BaseObject

Interface BaseObject

src/py_class/mod.rs:114–130  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

112
113/// A PythonObject that is usable as a base type with the `py_class!()` macro.
114pub trait BaseObject: PythonObject {
115 /// Gets the size of the object, in bytes.
116 fn size() -> usize;
117
118 type InitType;
119
120 /// Allocates a new object (usually by calling ty->tp_alloc),
121 /// and initializes it using init_val.
122 /// `ty` must be derived from the Self type, and the resulting object
123 /// must be of type `ty`.
124 unsafe fn alloc(py: Python, ty: &PyType, init_val: Self::InitType) -> PyResult<PyObject>;
125
126 /// Calls the rust destructor for the object and frees the memory
127 /// (usually by calling ptr->ob_type->tp_free).
128 /// This function is used as tp_dealloc implementation.
129 unsafe fn dealloc(py: Python, obj: *mut ffi::PyObject);
130}
131
132impl BaseObject for PyObject {
133 #[inline]

Callers

nothing calls this directly

Implementers 1

mod.rssrc/py_class/mod.rs

Calls

no outgoing calls

Tested by

no test coverage detected