#[repr(transparent)]pub struct Header(pub u16);Expand description
Definition of the message header. Every message shall start with it.
Tuple Fields§
§0: u16Implementations§
Source§impl Header
impl Header
Sourcepub fn extended(&self) -> bool
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.
Sourcepub fn with_extended(self, value: bool) -> Self
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.
Sourcepub fn set_extended(&mut self, value: bool)
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.
Sourcepub fn num_objects(&self) -> usize
pub fn num_objects(&self) -> usize
The number of 32 bit data objects that follow the header.
Sourcepub fn with_num_objects(self, value: u8) -> Self
pub fn with_num_objects(self, value: u8) -> Self
The number of 32 bit data objects that follow the header.
Sourcepub fn set_num_objects(&mut self, value: u8)
pub fn set_num_objects(&mut self, value: u8)
The number of 32 bit data objects that follow the header.
Sourcepub fn message_id(&self) -> u8
pub fn message_id(&self) -> u8
A rolling counter, maintained by the originator of the message.
Sourcepub fn with_message_id(self, value: u8) -> Self
pub fn with_message_id(self, value: u8) -> Self
A rolling counter, maintained by the originator of the message.
Sourcepub fn set_message_id(&mut self, value: u8)
pub fn set_message_id(&mut self, value: u8)
A rolling counter, maintained by the originator of the message.
Sourcepub fn port_power_role(&self) -> PowerRole
pub fn port_power_role(&self) -> PowerRole
Indicate the port’s present power role (0 -> sink, 1 -> source).
Sourcepub fn with_port_power_role(self, value: PowerRole) -> Self
pub fn with_port_power_role(self, value: PowerRole) -> Self
Indicate the port’s present power role (0 -> sink, 1 -> source).
Sourcepub fn set_port_power_role(&mut self, value: PowerRole)
pub fn set_port_power_role(&mut self, value: PowerRole)
Indicate the port’s present power role (0 -> sink, 1 -> source).
Sourcepub fn spec_revision(
&self,
) -> Result<SpecificationRevision, <SpecificationRevision as TryFrom<u8>>::Error>
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
Sourcepub fn with_spec_revision(self, value: SpecificationRevision) -> Self
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
Sourcepub fn set_spec_revision(&mut self, value: SpecificationRevision)
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
Sourcepub fn port_data_role(&self) -> DataRole
pub fn port_data_role(&self) -> DataRole
The port’s data role (0 -> UFP, 1 -> DFP).
Sourcepub fn with_port_data_role(self, value: DataRole) -> Self
pub fn with_port_data_role(self, value: DataRole) -> Self
The port’s data role (0 -> UFP, 1 -> DFP).
Sourcepub fn set_port_data_role(&mut self, value: DataRole)
pub fn set_port_data_role(&mut self, value: DataRole)
The port’s data role (0 -> UFP, 1 -> DFP).
Sourcepub fn message_type_raw(&self) -> u8
pub fn message_type_raw(&self) -> u8
The type of message being sent. See [6.2.1.1.8] for details
Sourcepub fn with_message_type_raw(self, value: u8) -> Self
pub fn with_message_type_raw(self, value: u8) -> Self
The type of message being sent. See [6.2.1.1.8] for details
Sourcepub fn set_message_type_raw(&mut self, value: u8)
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
impl Header
Sourcepub fn new_template(
port_data_role: DataRole,
port_power_role: PowerRole,
spec_revision: SpecificationRevision,
) -> Self
pub fn new_template( port_data_role: DataRole, port_power_role: PowerRole, spec_revision: SpecificationRevision, ) -> Self
Create a header template with the given attributes.
Sourcepub fn new(
template: Self,
message_id: Counter,
message_type: MessageType,
num_objects: u8,
extended: bool,
) -> Self
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.
Sourcepub fn new_control(
template: Self,
message_id: Counter,
message_type: ControlMessageType,
) -> Self
pub fn new_control( template: Self, message_id: Counter, message_type: ControlMessageType, ) -> Self
Create a new control message header.
Sourcepub fn new_data(
template: Self,
message_id: Counter,
message_type: DataMessageType,
num_objects: u8,
) -> Self
pub fn new_data( template: Self, message_id: Counter, message_type: DataMessageType, num_objects: u8, ) -> Self
Create a new data message header.
Sourcepub fn new_extended(
template: Self,
message_id: Counter,
extended_message_type: ExtendedMessageType,
num_objects: u8,
) -> Self
pub fn new_extended( template: Self, message_id: Counter, extended_message_type: ExtendedMessageType, num_objects: u8, ) -> Self
Create a new extended message header.
Sourcepub fn from_bytes(buf: &[u8]) -> Result<Self, ParseError>
pub fn from_bytes(buf: &[u8]) -> Result<Self, ParseError>
Parse a header from its binary representation.
Sourcepub fn to_bytes(self, buf: &mut [u8]) -> usize
pub fn to_bytes(self, buf: &mut [u8]) -> usize
Serialize the header to its binary representation.
Sourcepub fn message_type(&self) -> MessageType
pub fn message_type(&self) -> MessageType
Extract the message type that the header encodes.
Trait Implementations§
impl Copy for Header
impl Eq for Header
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U> UnsafeFrom<U> for Twhere
U: Into<T>,
impl<T, U> UnsafeFrom<U> for Twhere
U: Into<T>,
Source§unsafe fn unsafe_from(other: U) -> T
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 Twhere
U: UnsafeFrom<T>,
impl<T, U> UnsafeInto<U> for Twhere
U: UnsafeFrom<T>,
Source§unsafe fn unsafe_into(self) -> U
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.