From f08f655065d1463c2dae834c603f6ef84121890f Mon Sep 17 00:00:00 2001 From: Dominik Werder Date: Wed, 27 Nov 2024 07:13:47 +0100 Subject: [PATCH] Api types --- src/apitypes.rs | 21 ++++++++++++++++++++- src/timebin.rs | 6 ------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/apitypes.rs b/src/apitypes.rs index 9a30bbc..085c65f 100644 --- a/src/apitypes.rs +++ b/src/apitypes.rs @@ -10,9 +10,28 @@ impl ContPayload for T where T: fmt::Debug + Serialize + Send {} pub trait UserApiType: ToCborValue {} pub trait ToUserFacingApiType { - fn to_user_facing_api_type(self) -> Box; + fn to_user_facing_api_type(self: Self) -> Box; + fn to_user_facing_api_type_box(self: Box) -> Box; } +#[derive(Debug, Serialize)] +pub struct EmptyStruct {} + +impl EmptyStruct { + pub fn new() -> Self { + Self {} + } +} + +impl ToCborValue for EmptyStruct { + fn to_cbor_value(&self) -> Result { + let ret = ciborium::Value::Map(Vec::new()); + Ok(ret) + } +} + +impl UserApiType for EmptyStruct {} + #[derive(Serialize)] pub struct ContainerEventsApi where diff --git a/src/timebin.rs b/src/timebin.rs index cb4a391..0a9179d 100644 --- a/src/timebin.rs +++ b/src/timebin.rs @@ -112,12 +112,6 @@ pub trait BinningggContainerEventsDyn: fn as_mergeable_dyn_mut(&mut self) -> &mut dyn MergeableDyn; } -impl ToUserFacingApiType for Box { - fn to_user_facing_api_type(self) -> Box { - let inner = *self; - } -} - impl MergeableDyn for Box where T: MergeableDyn,