use core::fmt; use std::future::Future; use super::coding::Coding; use crate::helpers::enc_vec; pub trait Request: fmt::Debug + Coding + Sized + 'static { type Response: fmt::Debug + Coding + 'static; } pub async fn respond(_: &R, rep: R::Response) -> Vec { enc_vec(&rep).await } pub async fn respond_with>( r: &R, f: impl FnOnce(&R) -> F, ) -> Vec { respond(r, f(r).await).await } pub trait Channel: 'static { type Req: Coding + Sized + 'static; type Notif: Coding + Sized + 'static; } pub trait MsgSet: Sync + 'static { type In: Channel; type Out: Channel; }