pub trait ProtocolMessagePart: ProtocolMessageWrapper {
type Error: From<String>;
// Provided methods
fn none() -> Self { ... }
fn new<T>(format: &BoxedFormat, message: T) -> Result<Self, LocalError>
where T: 'static + Serialize { ... }
fn is_none(&self) -> bool { ... }
fn assert_is_none(&self) -> Result<(), Self::Error> { ... }
fn verify_is_not<'de, T: Deserialize<'de>>(
&'de self,
format: &BoxedFormat,
) -> Result<(), MessageValidationError> { ... }
fn verify_is_some(&self) -> Result<(), MessageValidationError> { ... }
fn deserialize<'de, T>(
&'de self,
format: &BoxedFormat,
) -> Result<T, Self::Error>
where T: Deserialize<'de> { ... }
}
Expand description
A serialized part of the protocol message.
These would usually be generated separately by the round, but delivered together to
Round::receive_message
.
Required Associated Types§
Sourcetype Error: From<String>
type Error: From<String>
The error specific to deserializing this message.
Used to distinguish which deserialization failed in
Round::receive_message
and store the corresponding message in the evidence.
Provided Methods§
Sourcefn none() -> Self
fn none() -> Self
Creates an empty message.
Use in case the round does not send a message of this type.
Sourcefn new<T>(format: &BoxedFormat, message: T) -> Result<Self, LocalError>where
T: 'static + Serialize,
fn new<T>(format: &BoxedFormat, message: T) -> Result<Self, LocalError>where
T: 'static + Serialize,
Creates a new serialized message.
Sourcefn assert_is_none(&self) -> Result<(), Self::Error>
fn assert_is_none(&self) -> Result<(), Self::Error>
Returns Ok(())
if the message is indeed an empty message.
Sourcefn verify_is_not<'de, T: Deserialize<'de>>(
&'de self,
format: &BoxedFormat,
) -> Result<(), MessageValidationError>
fn verify_is_not<'de, T: Deserialize<'de>>( &'de self, format: &BoxedFormat, ) -> Result<(), MessageValidationError>
Returns Ok(())
if the message cannot be deserialized into T
.
This is intended to be used in the implementations of
Protocol::verify_direct_message_is_invalid
or
Protocol::verify_echo_broadcast_is_invalid
.
Sourcefn verify_is_some(&self) -> Result<(), MessageValidationError>
fn verify_is_some(&self) -> Result<(), MessageValidationError>
Returns Ok(())
if the message contains a payload.
This is intended to be used in the implementations of
Protocol::verify_direct_message_is_invalid
or
Protocol::verify_echo_broadcast_is_invalid
.
Sourcefn deserialize<'de, T>(
&'de self,
format: &BoxedFormat,
) -> Result<T, Self::Error>where
T: Deserialize<'de>,
fn deserialize<'de, T>(
&'de self,
format: &BoxedFormat,
) -> Result<T, Self::Error>where
T: Deserialize<'de>,
Deserializes the message into T
.
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.