Suppose I have a Rust struct like this:
#[derive(Serialize, Deserialize)]
#[serde(rename = "Elixir.MyPackage.Event")]
struct Event {
name: String,
duration: std::time::Duration,
}
And we create an instance like this:
Event { name: "foo".to_string(), duration: std::time::Duration::from_secs(10) }
Currently, rustler will convert it to this:
%{
:__struct__ => MyPackage.Event,
:name => "foo",
:duration => %{:__struct__ => "Duration", "nanos" => 0, "secs" => 10}
}
Is there a way to map std::time::Duration to Elixir.MyPackage.Duration instead?