Trait pyo3::type_object::PyTypeInfo [−][src]
pub unsafe trait PyTypeInfo: Sized {
type Type;
type BaseType: PyTypeInfo + PyTypeObject;
type Layout: PyLayout<Self>;
type BaseLayout: PySizedLayout<Self::BaseType>;
type Initializer: PyObjectInit<Self>;
type AsRefTarget: PyNativeType;
const NAME: &'static str;
const MODULE: Option<&'static str>;
const DESCRIPTION: &'static str;
const FLAGS: usize;
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject;
fn is_type_of(object: &PyAny) -> bool { ... }
fn is_exact_type_of(object: &PyAny) -> bool { ... }
}
Expand description
Python type information.
All Python native types(e.g., PyDict
) and #[pyclass]
structs implement this trait.
This trait is marked unsafe because:
- specifying the incorrect layout can lead to memory errors
- the return value of type_object must always point to the same PyTypeObject instance
Associated Types
type BaseType: PyTypeInfo + PyTypeObject
type BaseType: PyTypeInfo + PyTypeObject
Base class
type BaseLayout: PySizedLayout<Self::BaseType>
type BaseLayout: PySizedLayout<Self::BaseType>
Layout of Basetype.
type Initializer: PyObjectInit<Self>
type Initializer: PyObjectInit<Self>
Initializer for layout
type AsRefTarget: PyNativeType
type AsRefTarget: PyNativeType
Utility type to make Py::as_ref work
Associated Constants
const DESCRIPTION: &'static str
const DESCRIPTION: &'static str
Class doc string
Required methods
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
PyTypeObject instance for this type.
Provided methods
fn is_type_of(object: &PyAny) -> bool
fn is_type_of(object: &PyAny) -> bool
Checks if object
is an instance of this type or a subclass of this type.
fn is_exact_type_of(object: &PyAny) -> bool
fn is_exact_type_of(object: &PyAny) -> bool
Checks if object
is an instance of this type.