#[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§
Sourceconst CONTENTS_OFFSET: PyObjectOffset
const CONTENTS_OFFSET: PyObjectOffset
Gets the offset of the contents from the start of the struct in bytes.
Sourceconst BASIC_SIZE: Py_ssize_t
const BASIC_SIZE: Py_ssize_t
Used to set PyType_Spec::basicsize
(docs)
Sourceconst DICT_OFFSET: PyObjectOffset
const DICT_OFFSET: PyObjectOffset
Gets the offset of the dictionary from the start of the struct in bytes.
Sourceconst WEAKLIST_OFFSET: PyObjectOffset
const WEAKLIST_OFFSET: PyObjectOffset
Gets the offset of the weakref list from the start of the struct in bytes.
Required Methods§
Sourceunsafe fn contents_uninit(
obj: *mut PyObject,
) -> *mut MaybeUninit<PyClassObjectContents<T>>
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
Sourcefn contents(&self) -> &PyClassObjectContents<T>
fn contents(&self) -> &PyClassObjectContents<T>
Obtain a reference to the structure that contains the pyclass struct and associated metadata.
Sourcefn contents_mut(&mut self) -> &mut PyClassObjectContents<T>
fn contents_mut(&mut self) -> &mut PyClassObjectContents<T>
Obtain a mutable reference to the structure that contains the pyclass struct and associated metadata.
Sourcefn ob_base(&self) -> &<T::BaseType as PyClassBaseType>::LayoutAsBase
fn ob_base(&self) -> &<T::BaseType as PyClassBaseType>::LayoutAsBase
obtain a reference to the data at the start of the PyObject.
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§
Source§impl<T: PyClassImpl<Layout = Self>> PyClassObjectLayout<T> for PyStaticClassObject<T>
impl<T: PyClassImpl<Layout = Self>> PyClassObjectLayout<T> for PyStaticClassObject<T>
Source§impl<T: PyClass<Layout = Self>> PyClassObjectLayout<T> for PyVariableClassObject<T>
Available on Py_3_12 only.
impl<T: PyClass<Layout = Self>> PyClassObjectLayout<T> for PyVariableClassObject<T>
Py_3_12 only.