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