pub trait ReactiveMessagingSerializer<LocalPeerMessages: ReactiveMessagingSerializer<LocalPeerMessages> + Send + PartialEq + Debug> {
// Required methods
fn serialize(remote_message: &LocalPeerMessages, buffer: &mut Vec<u8>);
fn processor_error_message(err: String) -> LocalPeerMessages;
}
Expand description
Trait that should be implemented by enums that model the “local messages” to be sent to the remote peer –
“local messages” may either be messages generated by the server or by the client, depending on if you’re building a server or client.
This trait, therefore, specifies how to:
serialize()
enum variants into a String (like RON, for textual protocols) to be sent to the remote peer- inform the peer if any wrong input was sent – the network processor will handle that special case.
Required Methods§
sourcefn serialize(remote_message: &LocalPeerMessages, buffer: &mut Vec<u8>)
fn serialize(remote_message: &LocalPeerMessages, buffer: &mut Vec<u8>)
Local messages serializer: transforms a strong typed message
into a sequence of bytes, put in buffer
– not appending any ‘\n’.
IMPLEMENTORS: #[inline(always)]
sourcefn processor_error_message(err: String) -> LocalPeerMessages
fn processor_error_message(err: String) -> LocalPeerMessages
Called whenever the local processor found an error – the returned message should be as descriptive as possible.
IMPLEMENTORS: #[inline(always)]
Implementations on Foreign Types§
source§impl ReactiveMessagingSerializer<String> for String
impl ReactiveMessagingSerializer<String> for String
Test implementation for our text-only protocol