Trait nardol::MetaDataType
source · [−]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<Option<<C as ContentType<'a, M, C>>::SendContext>, Error>;
fn receive(
stream: &mut TcpStream,
context: &Option<Self::ReceiveContext>
) -> Result<(Self, Option<<C as ContentType<'a, M, C>>::ReceiveContext>), Error>;
}
Expand description
Trait that needs to be implemented for type that will be used as metadata
inside a message
.
Required Associated Types
type SendContext: ContextType
type SendContext: ContextType
Context provided to MetaDataType::send from TcpMessage::send.
Context provided to MetaDataType::receive.
Required Methods
fn send(
self,
stream: &mut TcpStream,
context: Option<Self::SendContext>
) -> Result<Option<<C as ContentType<'a, M, C>>::SendContext>, Error>
fn send(
self,
stream: &mut TcpStream,
context: Option<Self::SendContext>
) -> Result<Option<<C as ContentType<'a, M, C>>::SendContext>, Error>
Send method used to send metadata
inside
TcpMessage::send.
Defines how are metadata
send.
Returns an Option of ContentType::SendContext on associated C that is passed into ContentType::send in TcpMessage::send. or an Error if not.
Arguments
stream
– TcpStream on which are data being sent.context
– Optional context provided from TcpMessage::send which is MetaDataType::SendContext
fn receive(
stream: &mut TcpStream,
context: &Option<Self::ReceiveContext>
) -> Result<(Self, Option<<C as ContentType<'a, M, C>>::ReceiveContext>), Error>
fn receive(
stream: &mut TcpStream,
context: &Option<Self::ReceiveContext>
) -> Result<(Self, Option<<C as ContentType<'a, M, C>>::ReceiveContext>), Error>
Receive method used to receive metadata
inside
TcpMessage::receive.
Defines how metadata
are received.
Returns a tuple of Self
and an Option of ContentType::ReceiveContext on associated
C that is passed into ContentType::receive in
TcpMessage::send if successful or an Error if not.
Arguments
stream
– TcpStream on which are data being received.context
– Optional context provided from TcpMessage::receive which is MetaDataType::ReceiveContext