use mizan_rust::{MizanClient, MizanError}; {% if !type_imports.is_empty() -%} use crate::types::{ {{- type_imports|join(", ") -}} }; {% endif -%} pub async fn call_{{ snake }}(client: &MizanClient{% match input %}{% when CallInput::Typed with (t) %}, args: &{{ crate::emit::casing::rust_type_ident(t) }}{% when CallInput::Absent %}{% endmatch %}) -> Result<{% if nullable %}Option<{{ output_type }}>{% else %}{{ output_type }}{% endif %}, MizanError> { let args_value = {% match input %}{% when CallInput::Typed with (t) %}serde_json::to_value(args) .map_err(|e| MizanError::transport(format!("encode {{ name }} args: {e}")))?{% when CallInput::Absent %}serde_json::Value::Object(Default::default()){% endmatch %}; let raw = client.call("{{ name }}", args_value).await?; serde_json::from_value(raw) .map_err(|e| MizanError::transport(format!("decode {{ name }} result: {e}"))) }