pub trait ReactiveMessagingSerializer<LocalPeerMessages> {
// Required methods
fn serialize(local_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(local_message: &LocalPeerMessages, buffer: &mut Vec<u8>)
fn serialize(local_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)]
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.
Implementations on Foreign Types§
Source§impl ReactiveMessagingSerializer<String> for String
Test implementation for our text-only protocol as used across this module
impl ReactiveMessagingSerializer<String> for String
Test implementation for our text-only protocol as used across this module