Skip to main content

PyClassObjectLayout

Trait PyClassObjectLayout 

Source
#[doc(hidden)]
pub trait PyClassObjectLayout<T: PyClassImpl>: PyClassObjectBaseLayout<T> { const CONTENTS_OFFSET: PyObjectOffset; const BASIC_SIZE: Py_ssize_t; const DICT_OFFSET: PyObjectOffset; const WEAKLIST_OFFSET: PyObjectOffset; // Required methods unsafe fn contents_uninit( obj: *mut PyObject, ) -> *mut MaybeUninit<PyClassObjectContents<T>>; fn contents(&self) -> &PyClassObjectContents<T>; fn contents_mut(&mut self) -> &mut PyClassObjectContents<T>; fn get_ptr(&self) -> *mut T; fn ob_base(&self) -> &<T::BaseType as PyClassBaseType>::LayoutAsBase; fn borrow_checker( &self, ) -> &<T::PyClassMutability as PyClassMutability>::Checker; }
Expand description

Functionality required for creating and managing the memory associated with a pyclass annotated struct.

Required Associated Constants§

Source

const CONTENTS_OFFSET: PyObjectOffset

Gets the offset of the contents from the start of the struct in bytes.

Source

const BASIC_SIZE: Py_ssize_t

Used to set PyType_Spec::basicsize (docs)

Source

const DICT_OFFSET: PyObjectOffset

Gets the offset of the dictionary from the start of the struct in bytes.

Source

const WEAKLIST_OFFSET: PyObjectOffset

Gets the offset of the weakref list from the start of the struct in bytes.

Required Methods§

Source

unsafe fn contents_uninit( obj: *mut PyObject, ) -> *mut MaybeUninit<PyClassObjectContents<T>>

Obtain a pointer to the contents of an uninitialized PyObject of this type.

SAFETY: obj must have the layout that the implementation is expecting

Source

fn contents(&self) -> &PyClassObjectContents<T>

Obtain a reference to the structure that contains the pyclass struct and associated metadata.

Source

fn contents_mut(&mut self) -> &mut PyClassObjectContents<T>

Obtain a mutable reference to the structure that contains the pyclass struct and associated metadata.

Source

fn get_ptr(&self) -> *mut T

Obtain a pointer to the pyclass struct.

Source

fn ob_base(&self) -> &<T::BaseType as PyClassBaseType>::LayoutAsBase

obtain a reference to the data at the start of the PyObject.

Source

fn borrow_checker( &self, ) -> &<T::PyClassMutability as PyClassMutability>::Checker

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here