pyo3::prelude

Trait PyMappingProxyMethods

Source
pub trait PyMappingProxyMethods<'py, 'a>: Sealed {
    // Required methods
    fn is_empty(&self) -> PyResult<bool>;
    fn keys(&self) -> PyResult<Bound<'py, PyList>>;
    fn values(&self) -> PyResult<Bound<'py, PyList>>;
    fn items(&self) -> PyResult<Bound<'py, PyList>>;
    fn as_mapping(&self) -> &Bound<'py, PyMapping>;
    fn try_iter(&'a self) -> PyResult<BoundMappingProxyIterator<'py, 'a>>;
}
Expand description

Implementation of functionality for PyMappingProxy.

These methods are defined for the Bound<'py, PyMappingProxy> smart pointer, so to use method call syntax these methods are separated into a trait, because stable Rust does not yet support arbitrary_self_types.

Required Methods§

Source

fn is_empty(&self) -> PyResult<bool>

Checks if the mappingproxy is empty, i.e. len(self) == 0.

Source

fn keys(&self) -> PyResult<Bound<'py, PyList>>

Returns a list containing all keys in the mapping.

Source

fn values(&self) -> PyResult<Bound<'py, PyList>>

Returns a list containing all values in the mapping.

Source

fn items(&self) -> PyResult<Bound<'py, PyList>>

Returns a list of tuples of all (key, value) pairs in the mapping.

Source

fn as_mapping(&self) -> &Bound<'py, PyMapping>

Returns self cast as a PyMapping.

Source

fn try_iter(&'a self) -> PyResult<BoundMappingProxyIterator<'py, 'a>>

Takes an object and returns an iterator for it. Returns an error if the object is not iterable.

Implementors§

Source§

impl<'py, 'a> PyMappingProxyMethods<'py, 'a> for Bound<'py, PyMappingProxy>