Trait pyo3::type_object::PyTypeCheck

source ·
pub trait PyTypeCheck: HasPyGilRef {
    const NAME: &'static str;

    // Required method
    fn type_check(object: &Bound<'_, PyAny>) -> bool;
}
Expand description

Implemented by types which can be used as a concrete Python type inside Py<T> smart pointers.

Required Associated Constants§

source

const NAME: &'static str

Name of self. This is used in error messages, for example.

Required Methods§

source

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype.

This should be equivalent to the Python expression isinstance(object, Self).

Object Safety§

This trait is not object safe.

Implementors§

source§

impl PyTypeCheck for PyIterator

source§

const NAME: &'static str = "Iterator"

source§

impl PyTypeCheck for PyMapping

source§

const NAME: &'static str = "Mapping"

source§

impl PyTypeCheck for PySequence

source§

const NAME: &'static str = "Sequence"

source§

impl<T> PyTypeCheck for PyCell<T>
where T: PyClass,

source§

const NAME: &'static str = <T as PyTypeCheck>::NAME

source§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

source§

const NAME: &'static str = <T as PyTypeInfo>::NAME