alef 0.107.9

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

    fn __str__(&self) -> PyResult<String> {
{%- if redact %}
        Ok("{{ name }}(<redacted>)".to_string())
{%- else %}
        serde_json::to_value({{ value_expr }})
            .map(|value| match value {
                serde_json::Value::String(value) => value,
                other => other.to_string(),
            })
            .map_err(|e| pyo3::exceptions::PyRuntimeError::new_err(format!("Failed to serialize {{ name }}: {e}")))
{%- endif %}
    }

    fn __repr__(&self) -> PyResult<String> {
        self.__str__()
    }