use std::net::TcpStream;
use crate::error::Error;
use crate::message::{ContentType, ContextType};
type SendContextOption<'a, M, C> = Option<<C as ContentType<'a, M, C>>::SendContext>;
type ReceiveContextOption<'a, M, C> = Option<<C as ContentType<'a, M, C>>::ReceiveContext>;
pub trait MetaDataType<'a, M, C>
where
Self: Sized,
M: MetaDataType<'a, M, C>,
C: ContentType<'a, M, C>,
{
type SendContext: ContextType;
type ReceiveContext: ContextType;
fn send(
self,
stream: &mut TcpStream,
context: Option<Self::SendContext>,
) -> Result<SendContextOption<'a, M, C>, Error>;
fn receive(
stream: &mut TcpStream,
context: &Option<Self::ReceiveContext>,
) -> Result<(Self, ReceiveContextOption<'a, M, C>), Error>;
}