pub struct DecryptedDataPayload<T>(/* private fields */);
Expand description

DecryptedDataPayload represents a decrypted DataPayload.

It can be built either directly through the new or using the EncryptedDataPayload.decrypt function.

Implementations§

source§

impl<T> DecryptedDataPayload<T>

source

pub fn to_inner(self) -> T

source§

impl<T: AsRef<[u8]>> DecryptedDataPayload<T>

source

pub fn frm_payload(&self) -> FRMPayload<'_>

Returns FRMPayload that can represent either application payload or mac commands if fport is 0.

source§

impl<T: AsRef<[u8]> + AsMut<[u8]>> DecryptedDataPayload<T>

source

pub fn new<'a>( data: T, nwk_skey: &'a AES128, app_skey: Option<&'a AES128>, fcnt: u32 ) -> Result<Self, Error>

Creates a DecryptedDataPayload from the bytes of a DataPayload.

The DataPayload payload is automatically decrypted and the mic is verified.

Argument
  • nwk_skey - the Network Session key used to decrypt the mac commands in case the payload is transporting those.
  • app_skey - the Application Session key used to decrypt the application payload in case the payload is transporting that.
  • fcnt - the counter used to encrypt the payload.
Examples
let mut data = vec![0x40, 0x04, 0x03, 0x02, 0x01, 0x80, 0x01, 0x00, 0x01,
    0xa6, 0x94, 0x64, 0x26, 0x15, 0xd6, 0xc3, 0xb5, 0x82];
let nwk_skey = lorawan::keys::AES128([2; 16]);
let app_skey = lorawan::keys::AES128([1; 16]);
let dec_phy = lorawan::parser::DecryptedDataPayload::new(data,
    &nwk_skey,
    Some(&app_skey),
    1).unwrap();

Trait Implementations§

source§

impl<T: AsRef<[u8]>> DataHeader for DecryptedDataPayload<T>

source§

fn as_data_bytes(&self) -> &[u8]

Equivalent to AsRef<u8>.
source§

fn fhdr(&self) -> FHDR<'_>

Gives the FHDR of the DataPayload.
source§

fn is_confirmed(&self) -> bool

Gives whether the frame is confirmed
Gives whether the payload is uplink or not.
source§

fn f_port(&self) -> Option<u8>

Gives the FPort of the DataPayload if there is one.
source§

fn fhdr_length(&self) -> usize

Gives the length of the FHDR field.
source§

impl<T: Debug> Debug for DecryptedDataPayload<T>

source§

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

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

impl<T: PartialEq> PartialEq for DecryptedDataPayload<T>

source§

fn eq(&self, other: &DecryptedDataPayload<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Eq> Eq for DecryptedDataPayload<T>

source§

impl<T> StructuralEq for DecryptedDataPayload<T>

source§

impl<T> StructuralPartialEq for DecryptedDataPayload<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for DecryptedDataPayload<T>
where T: RefUnwindSafe,

§

impl<T> Send for DecryptedDataPayload<T>
where T: Send,

§

impl<T> Sync for DecryptedDataPayload<T>
where T: Sync,

§

impl<T> Unpin for DecryptedDataPayload<T>
where T: Unpin,

§

impl<T> UnwindSafe for DecryptedDataPayload<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> AsPhyPayloadBytes for T
where T: DataHeader,

source§

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

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> MHDRAble for T

source§

fn mhdr(&self) -> MHDR

Gives the MIC of the PhyPayload.
source§

impl<T> MICAble for T

source§

fn mic(&self) -> MIC

Gives the MIC of the PhyPayload.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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.