Skip to main content

MessageMut

Struct MessageMut 

Source
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>

Source

pub fn as_slice(&self) -> &[u8]

Returns the underlying byte slice of the entire message.

Source

pub fn as_mut_slice(&mut self) -> &mut [u8]

Returns the underlying mutable byte slice of the entire message.

Source

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.

Source

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.

Source

pub fn set_size(&mut self, size: usize) -> Result<()>

Sets the total size of the message in its header.

Source

pub fn set_msg_id(&mut self, msg_id: MsgId) -> Result<()>

Sets the message ID in the message header.

Source

pub fn set_header_version(&mut self, version: u16) -> Result<()>

Sets the header version in the message header.

Source

pub fn set_apid(&mut self, apid: u16) -> Result<()>

Sets the APID in the message header.

Source

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.

Source

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.

Source

pub fn set_sequence_count(&mut self, count: u16) -> Result<()>

Sets the sequence count in the message header.

Source

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.

Source

pub fn set_type(&mut self, msg_type: MsgType) -> Result<()>

Sets the message type (Command or Telemetry) in the header.

Source

pub fn set_has_secondary_header(&mut self, has_secondary: bool) -> Result<()>

Sets the flag indicating whether a secondary header is present.

Source

pub unsafe fn user_data(&mut self) -> *mut c_void

Gets a raw pointer to the user data portion of the message.

§C-API Mapping

This is a wrapper for CFE_SB_GetUserData.

§Safety

The caller must ensure the returned pointer is cast to the correct payload struct type and that the size of the payload struct does not exceed the user data length.

Source

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.

Source

pub fn user_data_length(&self) -> usize

Gets the length of the user data portion of the message.

Source

pub fn set_user_data_length(&mut self, length: usize)

Sets the length of the user data portion of the message.

Source

pub fn timestamp(&mut self)

Sets the time field in the message header with the current spacecraft time.

Source

pub fn set_segmentation_flag(&mut self, flag: c_uint) -> Result<()>

Sets the segmentation flag in the message header.

Source

pub fn set_eds_version(&mut self, version: u16) -> Result<()>

Sets the EDS version in the message header.

Source

pub fn set_endian(&mut self, endian: c_uint) -> Result<()>

Sets the endianness indicator in the message header.

Source

pub fn set_playback_flag(&mut self, flag: c_uint) -> Result<()>

Sets the playback flag in the message header.

Source

pub fn set_subsystem(&mut self, subsystem: u16) -> Result<()>

Sets the subsystem ID in the message header.

Source

pub fn set_system(&mut self, system: u16) -> Result<()>

Sets the system ID in the message header.

Trait Implementations§

Source§

impl<'a> Debug for MessageMut<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for MessageMut<'a>

§

impl<'a> RefUnwindSafe for MessageMut<'a>

§

impl<'a> Send for MessageMut<'a>

§

impl<'a> Sync for MessageMut<'a>

§

impl<'a> Unpin for MessageMut<'a>

§

impl<'a> UnsafeUnpin for MessageMut<'a>

§

impl<'a> !UnwindSafe for MessageMut<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.