Trait pythonize::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

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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

§

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§