pub struct PacketHeader {
pub component: u16,
pub command: u16,
pub error: u16,
pub ty: PacketType,
pub id: u16,
}Expand description
Structure of packet header which comes before the packet content and describes it.
Fields§
§component: u16The component of this packet
command: u16The command of this packet
error: u16A possible error this packet contains (zero is none)
ty: PacketTypeThe type of this packet
id: u16The unique ID of this packet (Notify packets this is just zero)
Implementations§
Source§impl PacketHeader
impl PacketHeader
Sourcepub const fn notify(component: u16, command: u16) -> Self
pub const fn notify(component: u16, command: u16) -> Self
Creates a notify header for the provided component and command
component The component to use
command The command to use
Sourcepub const fn request(id: u16, component: u16, command: u16) -> Self
pub const fn request(id: u16, component: u16, command: u16) -> Self
Creates a request header for the provided id, component and command
id The packet ID
component The component to use
command The command to use
Sourcepub const fn response(&self) -> Self
pub const fn response(&self) -> Self
Creates a response to the provided packet header by changing the type of the header
Sourcepub const fn with_type(&self, ty: PacketType) -> Self
pub const fn with_type(&self, ty: PacketType) -> Self
Copies the header contents changing its Packet Type
ty The new packet type
Sourcepub const fn with_error(&self, error: u16) -> Self
pub const fn with_error(&self, error: u16) -> Self
Copies the header contents changing its Packet Type
Sourcepub fn path_matches(&self, other: &PacketHeader) -> bool
pub fn path_matches(&self, other: &PacketHeader) -> bool
Checks if the component and command of this packet header matches that of the other packet header
other The packet header to compare to
Trait Implementations§
Source§impl Clone for PacketHeader
impl Clone for PacketHeader
Source§fn clone(&self) -> PacketHeader
fn clone(&self) -> PacketHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PacketHeader
impl Debug for PacketHeader
Source§impl PartialEq for PacketHeader
impl PartialEq for PacketHeader
Source§fn eq(&self, other: &PacketHeader) -> bool
fn eq(&self, other: &PacketHeader) -> bool
self and other values to be equal, and is used by ==.