Skip to main content

Header

Struct Header 

Source
#[repr(transparent)]
pub struct Header(pub u16);
Expand description

Definition of the message header. Every message shall start with it.

Tuple Fields§

§0: u16

Implementations§

Source§

impl Header

Source

pub fn extended(&self) -> bool

Shall be set to zero to indicate a Control Message or Data Message and set to one to indicate an Extended Message.

Source

pub fn with_extended(self, value: bool) -> Self

Shall be set to zero to indicate a Control Message or Data Message and set to one to indicate an Extended Message.

Source

pub fn set_extended(&mut self, value: bool)

Shall be set to zero to indicate a Control Message or Data Message and set to one to indicate an Extended Message.

Source

pub fn num_objects(&self) -> usize

The number of 32 bit data objects that follow the header.

Source

pub fn with_num_objects(self, value: u8) -> Self

The number of 32 bit data objects that follow the header.

Source

pub fn set_num_objects(&mut self, value: u8)

The number of 32 bit data objects that follow the header.

Source

pub fn message_id(&self) -> u8

A rolling counter, maintained by the originator of the message.

Source

pub fn with_message_id(self, value: u8) -> Self

A rolling counter, maintained by the originator of the message.

Source

pub fn set_message_id(&mut self, value: u8)

A rolling counter, maintained by the originator of the message.

Source

pub fn port_power_role(&self) -> PowerRole

Indicate the port’s present power role (0 -> sink, 1 -> source).

Source

pub fn with_port_power_role(self, value: PowerRole) -> Self

Indicate the port’s present power role (0 -> sink, 1 -> source).

Source

pub fn set_port_power_role(&mut self, value: PowerRole)

Indicate the port’s present power role (0 -> sink, 1 -> source).

Source

pub fn spec_revision( &self, ) -> Result<SpecificationRevision, <SpecificationRevision as TryFrom<u8>>::Error>

The specification revision.

00b - Revision 1.0 (deprecated) 01b - Revision 2.0 10b - Revision 3.x 11b - Reserved, shall not be used

Source

pub fn with_spec_revision(self, value: SpecificationRevision) -> Self

The specification revision.

00b - Revision 1.0 (deprecated) 01b - Revision 2.0 10b - Revision 3.x 11b - Reserved, shall not be used

Source

pub fn set_spec_revision(&mut self, value: SpecificationRevision)

The specification revision.

00b - Revision 1.0 (deprecated) 01b - Revision 2.0 10b - Revision 3.x 11b - Reserved, shall not be used

Source

pub fn port_data_role(&self) -> DataRole

The port’s data role (0 -> UFP, 1 -> DFP).

Source

pub fn with_port_data_role(self, value: DataRole) -> Self

The port’s data role (0 -> UFP, 1 -> DFP).

Source

pub fn set_port_data_role(&mut self, value: DataRole)

The port’s data role (0 -> UFP, 1 -> DFP).

Source

pub fn message_type_raw(&self) -> u8

The type of message being sent. See [6.2.1.1.8] for details

Source

pub fn with_message_type_raw(self, value: u8) -> Self

The type of message being sent. See [6.2.1.1.8] for details

Source

pub fn set_message_type_raw(&mut self, value: u8)

The type of message being sent. See [6.2.1.1.8] for details

Source§

impl Header

Source

pub fn new_template( port_data_role: DataRole, port_power_role: PowerRole, spec_revision: SpecificationRevision, ) -> Self

Create a header template with the given attributes.

Source

pub fn new( template: Self, message_id: Counter, message_type: MessageType, num_objects: u8, extended: bool, ) -> Self

Create a new header that follows a template.

Source

pub fn new_control( template: Self, message_id: Counter, message_type: ControlMessageType, ) -> Self

Create a new control message header.

Source

pub fn new_data( template: Self, message_id: Counter, message_type: DataMessageType, num_objects: u8, ) -> Self

Create a new data message header.

Source

pub fn new_extended( template: Self, message_id: Counter, extended_message_type: ExtendedMessageType, num_objects: u8, ) -> Self

Create a new extended message header.

Source

pub fn from_bytes(buf: &[u8]) -> Result<Self, ParseError>

Parse a header from its binary representation.

Source

pub fn to_bytes(self, buf: &mut [u8]) -> usize

Serialize the header to its binary representation.

Source

pub fn message_type(&self) -> MessageType

Extract the message type that the header encodes.

Trait Implementations§

Source§

impl Bitfield for Header

Source§

type Storage = u16

This bitfield’s storage type.
Source§

impl Clone for Header

Source§

fn clone(&self) -> Header

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Header

Source§

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

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

impl From<Header> for u16

Source§

fn from(other: Header) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Header

Source§

fn from(other: u16) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Header

Source§

fn eq(&self, other: &Header) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Header

Source§

impl Eq for Header

Source§

impl StructuralPartialEq for Header

Auto Trait Implementations§

§

impl Freeze for Header

§

impl RefUnwindSafe for Header

§

impl Send for Header

§

impl Sync for Header

§

impl Unpin for Header

§

impl UnwindSafe for Header

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, 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.
Source§

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

Source§

unsafe fn unsafe_from(other: U) -> T

Calls U::into(other).

That is, this conversion is whatever the implementation of Into<T> for U chooses to do.

Source§

impl<T, U> UnsafeInto<U> for T
where U: UnsafeFrom<T>,

Source§

unsafe fn unsafe_into(self) -> U

Calls U::unsafe_from(self).

That is, this conversion is whatever the implementation of UnsafeFrom<T> for U chooses to do.