pub trait SocketServerSerializer<LocalPeerMessages: SocketServerSerializer<LocalPeerMessages> + Send + PartialEq + Debug> {
    // Required methods
    fn serialize(remote_message: &LocalPeerMessages, buffer: &mut Vec<u8>);
    fn processor_error_message(err: String) -> LocalPeerMessages;
    fn is_disconnect_message(processor_answer: &LocalPeerMessages) -> bool;
    fn is_no_answer_message(processor_answer: &LocalPeerMessages) -> bool;
}Expand description
Trait that should be implemented by enums that model the “local messages” to be handled by the [SocketServer] –
“local messages” are, typically, server messages (see [ServerMessages]) – but may also be client messages if we’re building a client (for tests?)
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
 - identify local messages that should cause a disconnection
 
Required Methods§
sourcefn serialize(remote_message: &LocalPeerMessages, buffer: &mut Vec<u8>)
 
fn serialize(remote_message: &LocalPeerMessages, buffer: &mut Vec<u8>)
SocketServers 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 socket server found an error – the returned message should be as descriptive as possible.
IMPLEMENTORS: #[inline(always)]
sourcefn is_disconnect_message(processor_answer: &LocalPeerMessages) -> bool
 
fn is_disconnect_message(processor_answer: &LocalPeerMessages) -> bool
Informs if the given internal processor_answer is a “disconnect” message (usually issued by the messages processor)
– in which case, the socket server will send it and, immediately, close the connection.
IMPLEMENTORS: #[inline(always)]
sourcefn is_no_answer_message(processor_answer: &LocalPeerMessages) -> bool
 
fn is_no_answer_message(processor_answer: &LocalPeerMessages) -> bool
Tells if the given processor_answer represents a “no message” – a message that should produce no answer to the peer.
IMPLEMENTORS: #[inline(always)]
Implementations on Foreign Types§
source§impl SocketServerSerializer<String> for String
 
impl SocketServerSerializer<String> for String
Test implementation for our text-only protocol