Skip to main content

MessageRef

Struct MessageRef 

Source
pub struct MessageRef<'a> { /* private fields */ }
Expand description

A safe, read-only wrapper around a CFE message byte slice.

This provides methods to access header fields without needing unsafe code or raw pointers in your application.

Implementations§

Source§

impl<'a> MessageRef<'a>

Source

pub fn new(slice: &'a [u8]) -> Self

Creates a new MessageRef from a byte slice.

Source

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

Returns the underlying byte slice of the entire message.

Source

pub fn header_version(&self) -> Result<u16>

Gets the header version from the message header.

Source

pub fn apid(&self) -> Result<u16>

Gets the APID from the message header.

Source

pub fn size(&self) -> Result<usize>

Gets the total size of the message from its header.

Source

pub fn msg_id(&self) -> Result<MsgId>

Gets the message ID from the message header.

Source

pub fn fcn_code(&self) -> Result<u16>

Gets the function code from a command message header.

Returns an error if the message does not have a secondary command header.

Source

pub fn time(&self) -> Result<SysTime>

Gets the timestamp from a telemetry message header.

Returns an error if the message does not have a secondary telemetry header.

Source

pub fn sequence_count(&self) -> Result<u16>

Gets the sequence count from the message header.

Source

pub fn validate_checksum(&self) -> Result<bool>

Validates the checksum of a command message.

Returns Ok(true) if the checksum is valid, Ok(false) if it is not. Returns an error if the message does not have a command secondary header.

Source

pub fn get_type(&self) -> Result<MsgType>

Gets the message type (Command or Telemetry) from the header.

Source

pub fn has_secondary_header(&self) -> Result<bool>

Checks if the message header indicates the presence of a secondary header.

Source

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

Gets a 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.

Source

pub fn user_data_length(&self) -> usize

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

Source

pub fn segmentation_flag(&self) -> Result<c_uint>

Gets the segmentation flag from the message header.

Source

pub fn eds_version(&self) -> Result<u16>

Gets the EDS version from the message header.

Source

pub fn endian(&self) -> Result<c_uint>

Gets the endianness indicator from the message header.

Source

pub fn playback_flag(&self) -> Result<c_uint>

Gets the playback flag from the message header.

Source

pub fn subsystem(&self) -> Result<u16>

Gets the subsystem ID from the message header.

Source

pub fn system(&self) -> Result<u16>

Gets the system ID from the message header.

Trait Implementations§

Source§

impl<'a> Clone for MessageRef<'a>

Source§

fn clone(&self) -> MessageRef<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for MessageRef<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> Copy for MessageRef<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for MessageRef<'a>

§

impl<'a> RefUnwindSafe for MessageRef<'a>

§

impl<'a> Send for MessageRef<'a>

§

impl<'a> Sync for MessageRef<'a>

§

impl<'a> Unpin for MessageRef<'a>

§

impl<'a> UnsafeUnpin for MessageRef<'a>

§

impl<'a> UnwindSafe for MessageRef<'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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.