pub trait MetaDataType<'a, M, C>{
type SendContext: ContextType;
type ReceiveContext: ContextType;
// Required methods
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§
Sourcetype SendContext: ContextType
type SendContext: ContextType
Context provided to MetaDataType::send from TcpMessage::send.
Sourcetype ReceiveContext: ContextType
type ReceiveContext: ContextType
Context provided to MetaDataType::receive.
Required Methods§
Sourcefn 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
Sourcefn 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
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.