Skip to main content

Packet

Enum Packet 

Source
pub enum Packet<'input> {
    Unsecured {
        basic: BasicHeader,
        common: CommonHeader,
        extended: Option<ExtendedHeader>,
        payload: &'input [u8],
    },
    Secured {
        basic: BasicHeader,
        secured: Ieee1609Dot2Data<'input>,
        common: CommonHeader,
        extended: Option<ExtendedHeader>,
    },
}
Expand description

C-ITS GeoNetworking packet

A geonetworking packet always contains a basic and common header. When message signing (secured packet) is used, a secured header is added after the basic header which signs all data following itself.

Usually a message will continue with an extended header. The payload is directly present in Unsecured packets or needs to be retrieved using Self::secured_payload_after_gn in Self::Secured

Variants§

§

Unsecured

Fields

§payload: &'input [u8]
§

Secured

Fields

§secured: Ieee1609Dot2Data<'input>

Implementations§

Source§

impl<'p> Packet<'p>

Source

pub fn secured_payload_after_gn(&self) -> Option<&'p [u8]>

Retrieves the slice of the secured IEEE 1609.2 data that represents the payload after GeoNetworking Common and Extended headers.

§Example

Consider a CAM message with BTB-B and secured GeoNetworking Header

Ieee1609Dot2Data->content->signed_data->tbs_data->payload->data->content->unsecured_data
|---Common---|---Extended---|--BTP-B--|--------CAM---------|
                            ^                              ^
                            |_________return slice_________|
Source

pub fn common(&self) -> &CommonHeader

Returns a reference to the Common header regardless of Packet type

Source

pub fn basic(&self) -> &BasicHeader

Returns a reference to the Basic header regardless of Packet type

Source

pub fn extended(&self) -> &Option<ExtendedHeader>

Returns a reference to the Extended header regardless of Packet type

Source

pub fn payload(&self) -> Option<&'p [u8]>

Returns a reference to the payload of a signed or unsigned packet (or None if secured packet has not payload)

The payload buffer will contain a header (usually BTP) as specified in the next_header field of the common header.

Source

pub fn btp_payload(&self) -> Result<&'p [u8], String>

Extracts the BTP payload

§Errors

Returns a human-readable string if

  • a secured packet has no payload
  • or the next header is not a BTP header
Source

pub fn is_hopped(&self) -> bool

Determines if the packet was hopped

Source

pub fn is_secured(&self) -> bool

Determines if the packet is a secured packet

Source

pub fn source_position_vector(&self) -> Option<LongPositionVector>

Gets the source position vector from the extended header (if header is present)

Trait Implementations§

Source§

impl<'input> Clone for Packet<'input>

Source§

fn clone(&self) -> Packet<'input>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'input> Debug for Packet<'input>

Source§

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

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

impl<'s> Decode<'s> for Packet<'s>

Source§

fn decode<'input: 's, I: Into<&'input [u8]>>( input: I, ) -> Result<Decoded<Self>, DecodeError<&'input [u8]>>

Decodes the data type from a binary buffer Read more
Source§

impl Encode for Packet<'_>

Source§

fn encode(&self, output: &mut Encoder) -> Result<(), EncodeError>

Encodes itself as binary data to the output Encoder Read more
Source§

fn encode_to_vec(&self) -> Result<Vec<u8>, EncodeError>

Encodes itself as binary data Read more
Source§

fn encode_to_json(&self) -> Result<String, EncodeError>
where Self: Sized + Serialize,

Encodes itself to a JSON representation Read more
Source§

impl<'input> PartialEq for Packet<'input>

Source§

fn eq(&self, other: &Packet<'input>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<'input> Serialize for Packet<'input>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'input> StructuralPartialEq for Packet<'input>

Source§

impl Validate for Packet<'_>

Source§

fn validate(&self) -> Result<ValidationResult, ValidationError>

Checks whether the implementing type is valid. Read more

Auto Trait Implementations§

§

impl<'input> Freeze for Packet<'input>

§

impl<'input> RefUnwindSafe for Packet<'input>

§

impl<'input> Send for Packet<'input>

§

impl<'input> Sync for Packet<'input>

§

impl<'input> Unpin for Packet<'input>

§

impl<'input> UnsafeUnpin for Packet<'input>

§

impl<'input> UnwindSafe for Packet<'input>

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

Source§

type Output = T

Should always be Self
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.