pub struct Message<'a> {
pub transaction_id: &'a [u8],
pub group_no: u8,
pub abort_on_error: u8,
pub body: Body<'a>,
}Expand description
One SML message.
Fields§
§transaction_id: &'a [u8]Identifies a request and its response.
group_no: u8Groups messages that belong together.
abort_on_error: u8What the receiver does when this message fails (0 = continue).
body: Body<'a>The message body.
Implementations§
Source§impl<'a> Message<'a>
impl<'a> Message<'a>
Sourcepub fn read(r: &mut Reader<'a>, options: ParseOptions) -> Result<Self>
pub fn read(r: &mut Reader<'a>, options: ParseOptions) -> Result<Self>
Parse one message at the reader’s position and check its CRC.
Sourcepub fn write(&self, w: &mut Writer<'_>) -> Result<()>
pub fn write(&self, w: &mut Writer<'_>) -> Result<()>
Write the message with its CRC (CRC-16/X-25, low byte first) and end-of-message byte.
Reading the result yields an equal message. The bytes may differ from the ones a
message was decoded from, because integer widths are not kept. An empty optional
octet string (Some(&[])) is written as 01, which SML reads as absent: the two
cannot be told apart on the wire.
Raw parts (Attention::details, Body::Other) must each be exactly one encoded
element, or the result is Error::InvalidLength and nothing is written that
would carry a valid CRC over a broken structure.