#[repr(C)]pub struct Telemetry<T: Copy> {
pub payload: T,
/* private fields */
}
Expand description
A cFS-flavor CCSDS telemetry packet, as a Rust structure.
Fields§
§payload: T
The message’s payload. As messages are copied
willy-nilly, T
needs to be Copy
.
Implementations§
source§impl<T: Copy> Telemetry<T>
impl<T: Copy> Telemetry<T>
sourcepub fn new(msg_id: u32, payload: T) -> Result<Self, ()>
pub fn new(msg_id: u32, payload: T) -> Result<Self, ()>
If msg_id
is a permissible message ID,
returns a new Telemetry
with the payload initialized to payload
; otherwise returns an error.
sourcepub fn new_default(msg_id: u32) -> Result<Self, ()>where
T: Default,
pub fn new_default(msg_id: u32) -> Result<Self, ()>where
T: Default,
Self::new
, but using Default::default
()
as the payload.
sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Returns a view of the Telemetry
as a sequence of bytes, ready for transmission.
sourcepub unsafe fn from_bytes(bytes: &[u8]) -> Result<Self, ()>
pub unsafe fn from_bytes(bytes: &[u8]) -> Result<Self, ()>
Turns a sequence of bytes representing a message into a Telemetry
,
assuming bytes
is the correct length and the header bytes have sane values.
§Safety
Using this function is only safe if the part of bytes
at bytes 16..(16 + std::mem::size_of::<T>())
is byte-for-byte equal to a valid item of type T
.
sourcepub fn timestamp(&self) -> (u32, u16)
pub fn timestamp(&self) -> (u32, u16)
Returns the message’s timestamp as a tuple of (seconds since flight-software epoch, subseconds in units of 2−16 s).
sourcepub fn sequence_number(&self) -> u16
pub fn sequence_number(&self) -> u16
Returns the message’s sequence number.
sourcepub fn set_msg_id(&mut self, msg_id: u32) -> Result<(), ()>
pub fn set_msg_id(&mut self, msg_id: u32) -> Result<(), ()>
If msg_id
is a valid message ID, uses it to set the message’s message ID.
sourcepub fn set_timestamp(&mut self, seconds: u64, nanoseconds: u32)
pub fn set_timestamp(&mut self, seconds: u64, nanoseconds: u32)
Sets the message’s timestamp to
seconds
seconds + nanoseconds
nanoseconds
since the flight-software epoch, rounded to 2−16 seconds.
sourcepub fn timestamp_with_now(&mut self) -> Result<(), SystemTimeError>
pub fn timestamp_with_now(&mut self) -> Result<(), SystemTimeError>
Sets the message’s timestamp to the current time.
sourcepub fn increment_sequence_num(&mut self)
pub fn increment_sequence_num(&mut self)
Increment the message’s sequence number.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Telemetry<T>where
T: Freeze,
impl<T> RefUnwindSafe for Telemetry<T>where
T: RefUnwindSafe,
impl<T> Send for Telemetry<T>where
T: Send,
impl<T> Sync for Telemetry<T>where
T: Sync,
impl<T> Unpin for Telemetry<T>where
T: Unpin,
impl<T> UnwindSafe for Telemetry<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)