pyo3::impl_::pyclass_init

Trait PyObjectInit

Source
pub trait PyObjectInit<T>: Sized + Sealed {
    // Required methods
    unsafe fn into_new_object(
        self,
        py: Python<'_>,
        subtype: *mut PyTypeObject,
    ) -> PyResult<*mut PyObject>;
    #[doc(hidden)] fn can_be_subclassed(&self) -> bool;
}
Expand description

Initializer for Python types.

This trait is intended to use internally for distinguishing #[pyclass] and Python native types.

Required Methods§

Source

unsafe fn into_new_object( self, py: Python<'_>, subtype: *mut PyTypeObject, ) -> PyResult<*mut PyObject>

§Safety
  • subtype must be a valid pointer to a type object of T or a subclass.
Source

#[doc(hidden)] fn can_be_subclassed(&self) -> bool

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