Skip to main content

indexmap_from_pyobject_pyo3

Function indexmap_from_pyobject_pyo3 

Source
pub fn indexmap_from_pyobject_pyo3<K, V>(
    py: Python<'_>,
    value: &Bound<'_, PyAny>,
) -> PyResult<IndexMap<K, V>>
where K: for<'py> FromPyObjectOwned<'py> + DeserializeOwned + Eq + Hash, V: for<'py> FromPyObjectOwned<'py> + DeserializeOwned, IndexMap<K, V>: DeserializeOwned,
Expand description

Convert a Python mapping to an IndexMap using typed PyO3 objects when possible.

Falls back to the generic JSON bridge when the input is not a Python dict. Individual dict keys and values first try typed PyO3 extraction, then JSON/Serde extraction. This accepts both {InstrumentId(...): Price(...)} and {"AUD/USD.SIM": "1.23456"} style inputs.

ยงErrors

Returns an error if the Python object cannot be converted to the requested map type.