pyo3::type_object

Trait PyTypeCheck

Source
pub trait PyTypeCheck {
    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).

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 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 PyTypeCheck for PyWeakref

Source§

const NAME: &'static str = "weakref"

Source§

impl PyTypeCheck for PyWeakrefProxy

Source§

const NAME: &'static str = "weakref.ProxyTypes"

Source§

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

Source§

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