ccsds_packet

Struct Telemetry

source
#[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>

source

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.

source

pub fn new_default(msg_id: u32) -> Result<Self, ()>
where T: Default,

Self::new, but using Default::default() as the payload.

source

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

Returns a view of the Telemetry as a sequence of bytes, ready for transmission.

source

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.

source

pub fn msg_id(&self) -> u32

Returns the message’s message ID.

source

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).

source

pub fn sequence_number(&self) -> u16

Returns the message’s sequence number.

source

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.

source

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.

source

pub fn timestamp_with_now(&mut self) -> Result<(), SystemTimeError>

Sets the message’s timestamp to the current time.

source

pub fn increment_sequence_num(&mut self)

Increment the message’s sequence number.

Trait Implementations§

source§

impl<T: Clone + Copy> Clone for Telemetry<T>

source§

fn clone(&self) -> Telemetry<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

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> 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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.