diff --git a/wasm-rpc/src/type_annotated_value.rs b/wasm-rpc/src/type_annotated_value.rs index d8c2becc..ca719db9 100644 --- a/wasm-rpc/src/type_annotated_value.rs +++ b/wasm-rpc/src/type_annotated_value.rs @@ -13,6 +13,7 @@ use golem_wasm_ast::analysis::analysed_type::{ use golem_wasm_ast::analysis::protobuf::Type; use golem_wasm_ast::analysis::AnalysedType; use std::collections::HashMap; +use std::time::{Duration, Instant}; use uuid::Uuid; #[derive(Clone, Debug, PartialEq)] @@ -510,6 +511,26 @@ impl IntoValue for Uri { } } +impl IntoValue for Instant { + fn into_value(self) -> Value { + Value::U64(self.elapsed().as_nanos() as u64) + } + + fn get_type() -> AnalysedType { + u64() + } +} + +impl IntoValue for Duration { + fn into_value(self) -> Value { + Value::U64(self.as_nanos() as u64) + } + + fn get_type() -> AnalysedType { + u64() + } +} + pub trait TypeAnnotatedValueConstructors: Sized { fn create>(value: &Value, typ: T) -> Result>; }