devela::_dep::pyo3

Trait PyTypeCheck

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

    // Required method
    fn type_check(object: &Bound<'_, PyAny>) -> bool;
}
Available on crate features dep_pyo3 and std only.
Expand description

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

Required Associated Constants§

const NAME: &'static str

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

Required Methods§

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§

§

impl PyTypeCheck for PyIterator

§

const NAME: &'static str = "Iterator"

§

impl PyTypeCheck for PyMapping

§

const NAME: &'static str = "Mapping"

§

impl PyTypeCheck for PySequence

§

const NAME: &'static str = "Sequence"

§

impl PyTypeCheck for PyWeakref

§

const NAME: &'static str = "weakref"

§

impl PyTypeCheck for PyWeakrefProxy

§

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

§

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

§

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