[][src]Struct ieee802154::mac::frame::header::ShortAddress

pub struct ShortAddress(pub u16);

A 16-bit short address

Short address assigned to a device during association, used to identify the device in the PAN.

Example

use ieee802154::mac::ShortAddress;

let short_address = ShortAddress(0x0123);

Implementations

impl ShortAddress[src]

pub const BROADCAST: Self[src]

An instance of ShortAddress that represents the broadcast address.

pub fn broadcast() -> Self[src]

Creates an instance of ShortAddress that represents the broadcast address

pub fn decode(buf: &mut dyn Buf) -> Result<Self, DecodeError>[src]

Decodes an address from a byte buffer

This method is used by Header::decode to decode addresses. Unless you decide to write your own code for decoding headers, there should be no reason to call this method directly.

Errors

This function returns an error, if there are not enough bytes in the buffer to encode a valid Address instance.

Example

use ieee802154::mac::frame::{DecodeError, header::ShortAddress};

let mut bytes = &[0x56, 0x78][..];
let address = ShortAddress::decode(&mut bytes)?;

assert_eq!(address, ShortAddress(0x7856));

pub fn encode(&self, buf: &mut dyn BufMut)[src]

Encodes the address into a buffer

Example

use ieee802154::mac::ShortAddress;

let address = ShortAddress(0x5678);

let mut bytes = bytes::BytesMut::with_capacity(2);
address.encode(&mut bytes);

let expected_bytes = [0x78, 0x56];
assert_eq!(bytes[..], expected_bytes[..]);

Trait Implementations

impl Clone for ShortAddress[src]

impl Copy for ShortAddress[src]

impl Debug for ShortAddress[src]

impl Eq for ShortAddress[src]

impl Hash for ShortAddress[src]

impl Hash for ShortAddress[src]

impl PartialEq<ShortAddress> for ShortAddress[src]

impl StructuralEq for ShortAddress[src]

impl StructuralPartialEq for ShortAddress[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.