Trait PythonizeMappingType

Source
pub trait PythonizeMappingType<'py> {
    type Builder;

    // Required methods
    fn builder(py: Python<'py>, len: Option<usize>) -> PyResult<Self::Builder>;
    fn push_item(
        builder: &mut Self::Builder,
        key: Bound<'py, PyAny>,
        value: Bound<'py, PyAny>,
    ) -> PyResult<()>;
    fn finish(builder: Self::Builder) -> PyResult<Bound<'py, PyMapping>>;
}
Expand description

Trait for types which can represent a Python mapping

Required Associated Types§

Source

type Builder

Builder type for Python mappings

Required Methods§

Source

fn builder(py: Python<'py>, len: Option<usize>) -> PyResult<Self::Builder>

Create a builder for a Python mapping

Source

fn push_item( builder: &mut Self::Builder, key: Bound<'py, PyAny>, value: Bound<'py, PyAny>, ) -> PyResult<()>

Adds the key-value item to the mapping being built

Source

fn finish(builder: Self::Builder) -> PyResult<Bound<'py, PyMapping>>

Build the Python mapping

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.

Implementations on Foreign Types§

Source§

impl<'py> PythonizeMappingType<'py> for PyDict

Source§

type Builder = Bound<'py, PyDict>

Source§

fn builder(py: Python<'py>, _len: Option<usize>) -> PyResult<Self::Builder>

Source§

fn push_item( builder: &mut Self::Builder, key: Bound<'py, PyAny>, value: Bound<'py, PyAny>, ) -> PyResult<()>

Source§

fn finish(builder: Self::Builder) -> PyResult<Bound<'py, PyMapping>>

Implementors§