Api types

This commit is contained in:
Dominik Werder
2024-11-27 07:13:47 +01:00
parent ec322b5f50
commit f08f655065
2 changed files with 20 additions and 7 deletions

View File

@@ -10,9 +10,28 @@ impl<T> ContPayload for T where T: fmt::Debug + Serialize + Send {}
pub trait UserApiType: ToCborValue {}
pub trait ToUserFacingApiType {
fn to_user_facing_api_type(self) -> Box<dyn UserApiType>;
fn to_user_facing_api_type(self: Self) -> Box<dyn UserApiType>;
fn to_user_facing_api_type_box(self: Box<Self>) -> Box<dyn UserApiType>;
}
#[derive(Debug, Serialize)]
pub struct EmptyStruct {}
impl EmptyStruct {
pub fn new() -> Self {
Self {}
}
}
impl ToCborValue for EmptyStruct {
fn to_cbor_value(&self) -> Result<ciborium::Value, ciborium::value::Error> {
let ret = ciborium::Value::Map(Vec::new());
Ok(ret)
}
}
impl UserApiType for EmptyStruct {}
#[derive(Serialize)]
pub struct ContainerEventsApi<EVT>
where

View File

@@ -112,12 +112,6 @@ pub trait BinningggContainerEventsDyn:
fn as_mergeable_dyn_mut(&mut self) -> &mut dyn MergeableDyn;
}
impl ToUserFacingApiType for Box<dyn BinningggContainerEventsDyn> {
fn to_user_facing_api_type(self) -> Box<dyn crate::apitypes::UserApiType> {
let inner = *self;
}
}
impl<T> MergeableDyn for Box<T>
where
T: MergeableDyn,