pub struct MessageMut<'a> { /* private fields */ }Expand description
A safe, writeable wrapper around a CFE message byte slice.
This provides methods to initialize and modify header fields. It is typically
used with a SendBuffer from the sb module.
Implementations§
Source§impl<'a> MessageMut<'a>
impl<'a> MessageMut<'a>
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8]
pub fn as_mut_slice(&mut self) -> &mut [u8]
Returns the underlying mutable byte slice of the entire message.
Sourcepub fn send(self, is_origination: bool) -> Result<()>
pub fn send(self, is_origination: bool) -> Result<()>
Transmits the message in this buffer.
The is_origination flag should be set to true if the message is being sent
as an original message from this application, or false if it is being relayed.
Sourcepub fn init(&mut self, msg_id: MsgId, size: usize) -> Result<()>
pub fn init(&mut self, msg_id: MsgId, size: usize) -> Result<()>
Initializes a message header within the buffer.
This routine zeroes the buffer up to size, sets default header fields,
and then populates the message ID and length fields.
Sourcepub fn set_size(&mut self, size: usize) -> Result<()>
pub fn set_size(&mut self, size: usize) -> Result<()>
Sets the total size of the message in its header.
Sourcepub fn set_msg_id(&mut self, msg_id: MsgId) -> Result<()>
pub fn set_msg_id(&mut self, msg_id: MsgId) -> Result<()>
Sets the message ID in the message header.
Sourcepub fn set_header_version(&mut self, version: u16) -> Result<()>
pub fn set_header_version(&mut self, version: u16) -> Result<()>
Sets the header version in the message header.
Sourcepub fn set_fcn_code(&mut self, fcn_code: u16) -> Result<()>
pub fn set_fcn_code(&mut self, fcn_code: u16) -> Result<()>
Sets the function code in a command message header.
Returns an error if the message does not have a secondary command header.
Sourcepub fn set_time(&mut self, new_time: SysTime) -> Result<()>
pub fn set_time(&mut self, new_time: SysTime) -> Result<()>
Sets the timestamp in a telemetry message header.
Returns an error if the message does not have a secondary telemetry header.
Sourcepub fn set_sequence_count(&mut self, count: u16) -> Result<()>
pub fn set_sequence_count(&mut self, count: u16) -> Result<()>
Sets the sequence count in the message header.
Sourcepub fn generate_checksum(&mut self) -> Result<()>
pub fn generate_checksum(&mut self) -> Result<()>
Calculates and sets the checksum field in a command message header.
Returns an error if the message does not have a command secondary header.
Sourcepub fn set_type(&mut self, msg_type: MsgType) -> Result<()>
pub fn set_type(&mut self, msg_type: MsgType) -> Result<()>
Sets the message type (Command or Telemetry) in the header.
Sourcepub fn set_has_secondary_header(&mut self, has_secondary: bool) -> Result<()>
pub fn set_has_secondary_header(&mut self, has_secondary: bool) -> Result<()>
Sets the flag indicating whether a secondary header is present.
Sourcepub fn payload<P: Sized>(&mut self) -> Result<&mut P>
pub fn payload<P: Sized>(&mut self) -> Result<&mut P>
Returns a mutable reference to the message payload, interpreted as type P.
This is the primary safe method for accessing the payload of a message.
It performs a size check to ensure the payload type P fits within the
available user data area of the message buffer, preventing buffer overruns.
§Errors
Returns Error::StatusWrongMsgLength if size_of::<P>() is larger
than the available user data length in the message buffer.
Sourcepub fn user_data_length(&self) -> usize
pub fn user_data_length(&self) -> usize
Gets the length of the user data portion of the message.
Sourcepub fn set_user_data_length(&mut self, length: usize)
pub fn set_user_data_length(&mut self, length: usize)
Sets the length of the user data portion of the message.
Sourcepub fn timestamp(&mut self)
pub fn timestamp(&mut self)
Sets the time field in the message header with the current spacecraft time.
Sourcepub fn set_segmentation_flag(&mut self, flag: c_uint) -> Result<()>
pub fn set_segmentation_flag(&mut self, flag: c_uint) -> Result<()>
Sets the segmentation flag in the message header.
Sourcepub fn set_eds_version(&mut self, version: u16) -> Result<()>
pub fn set_eds_version(&mut self, version: u16) -> Result<()>
Sets the EDS version in the message header.
Sourcepub fn set_endian(&mut self, endian: c_uint) -> Result<()>
pub fn set_endian(&mut self, endian: c_uint) -> Result<()>
Sets the endianness indicator in the message header.
Sourcepub fn set_playback_flag(&mut self, flag: c_uint) -> Result<()>
pub fn set_playback_flag(&mut self, flag: c_uint) -> Result<()>
Sets the playback flag in the message header.
Sourcepub fn set_subsystem(&mut self, subsystem: u16) -> Result<()>
pub fn set_subsystem(&mut self, subsystem: u16) -> Result<()>
Sets the subsystem ID in the message header.
Sourcepub fn set_system(&mut self, system: u16) -> Result<()>
pub fn set_system(&mut self, system: u16) -> Result<()>
Sets the system ID in the message header.