zero_trust_rps/common/connection/
writer.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use serde::Serialize;

#[derive(thiserror::Error, Debug)]
pub enum WriteMessageError {
    #[error("Serializing failed: {}", .0)]
    Serialize(#[from] postcard::Error),
    #[error("Writing failed: {}", .0)]
    Writing(#[from] quinn::WriteError),
}

pub trait Writer: Send {
    fn write_message<T: Serialize + Send>(
        &mut self,
        value: T,
    ) -> impl std::future::Future<Output = Result<(), WriteMessageError>> + Send;
}