PyTypeAlias

Trait PyTypeAlias 

Source
pub trait PyTypeAlias: PyStubType {
    const NAME: &'static str;
    const MODULE: &'static str;

    // Required method
    fn create_type_object(py: Python<'_>) -> PyResult<Bound<'_, PyAny>>;
}
Expand description

Trait for type aliases that can be registered at runtime.

This trait is automatically implemented by the type_alias! macro. It provides the metadata and factory method needed to register a type alias in a Python module.

§Associated Constants

  • NAME - The Python name of the type alias
  • MODULE - The module where the type alias is defined

§Required Methods

  • create_type_object - Creates the Python type object representing the alias

Required Associated Constants§

Source

const NAME: &'static str

The name of the type alias in Python.

Source

const MODULE: &'static str

The module path where this type alias is defined.

Required Methods§

Source

fn create_type_object(py: Python<'_>) -> PyResult<Bound<'_, PyAny>>

Creates the Python type object for this type alias.

For union types, this creates a union using the | operator.

§Arguments
  • py - Python interpreter token
§Returns

The Python type object representing this type alias.

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§