pub struct ZWaveLayer {
pub index: LayerIndex,
}Expand description
Z-Wave layer – a zero-copy view into a packet buffer.
Fields§
§index: LayerIndexImplementations§
Source§impl ZWaveLayer
impl ZWaveLayer
Sourcepub fn new(index: LayerIndex) -> Self
pub fn new(index: LayerIndex) -> Self
Create a new Z-Wave layer from a layer index.
Sourcepub fn at_start(end: usize) -> Self
pub fn at_start(end: usize) -> Self
Create a Z-Wave layer starting at offset 0 (for standalone parsing).
Sourcepub fn home_id(&self, buf: &[u8]) -> Result<u32, FieldError>
pub fn home_id(&self, buf: &[u8]) -> Result<u32, FieldError>
Read the 4-byte Home ID (big-endian u32) at offset 0.
Sourcepub fn set_home_id(&self, buf: &mut [u8], value: u32) -> Result<(), FieldError>
pub fn set_home_id(&self, buf: &mut [u8], value: u32) -> Result<(), FieldError>
Set the Home ID (big-endian u32) at offset 0.
Sourcepub fn set_src(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
pub fn set_src(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
Set the source node ID at offset 4.
Sourcepub fn frame_ctrl(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn frame_ctrl(&self, buf: &[u8]) -> Result<u8, FieldError>
Read the raw frame control byte at offset 5.
Sourcepub fn set_frame_ctrl(
&self,
buf: &mut [u8],
value: u8,
) -> Result<(), FieldError>
pub fn set_frame_ctrl( &self, buf: &mut [u8], value: u8, ) -> Result<(), FieldError>
Set the raw frame control byte at offset 5.
Sourcepub fn routed(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn routed(&self, buf: &[u8]) -> Result<bool, FieldError>
Get the routed flag (bit 7 of frame control).
Sourcepub fn set_routed(&self, buf: &mut [u8], value: bool) -> Result<(), FieldError>
pub fn set_routed(&self, buf: &mut [u8], value: bool) -> Result<(), FieldError>
Set the routed flag (bit 7 of frame control).
Sourcepub fn ackreq(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn ackreq(&self, buf: &[u8]) -> Result<bool, FieldError>
Get the ack request flag (bit 6 of frame control).
Sourcepub fn set_ackreq(&self, buf: &mut [u8], value: bool) -> Result<(), FieldError>
pub fn set_ackreq(&self, buf: &mut [u8], value: bool) -> Result<(), FieldError>
Set the ack request flag (bit 6 of frame control).
Sourcepub fn lowpower(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn lowpower(&self, buf: &[u8]) -> Result<bool, FieldError>
Get the low power flag (bit 5 of frame control).
Sourcepub fn set_lowpower(
&self,
buf: &mut [u8],
value: bool,
) -> Result<(), FieldError>
pub fn set_lowpower( &self, buf: &mut [u8], value: bool, ) -> Result<(), FieldError>
Set the low power flag (bit 5 of frame control).
Sourcepub fn speedmodified(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn speedmodified(&self, buf: &[u8]) -> Result<bool, FieldError>
Get the speed modified flag (bit 4 of frame control).
Sourcepub fn set_speedmodified(
&self,
buf: &mut [u8],
value: bool,
) -> Result<(), FieldError>
pub fn set_speedmodified( &self, buf: &mut [u8], value: bool, ) -> Result<(), FieldError>
Set the speed modified flag (bit 4 of frame control).
Sourcepub fn headertype(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn headertype(&self, buf: &[u8]) -> Result<u8, FieldError>
Get the header type (bits 3-0 of frame control).
Sourcepub fn set_headertype(
&self,
buf: &mut [u8],
value: u8,
) -> Result<(), FieldError>
pub fn set_headertype( &self, buf: &mut [u8], value: u8, ) -> Result<(), FieldError>
Set the header type (bits 3-0 of frame control).
Sourcepub fn beam_seqn(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn beam_seqn(&self, buf: &[u8]) -> Result<u8, FieldError>
Read the raw beam/sequence byte at offset 6.
Sourcepub fn set_beam_seqn(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
pub fn set_beam_seqn(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
Set the raw beam/sequence byte at offset 6.
Sourcepub fn beam_control(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn beam_control(&self, buf: &[u8]) -> Result<u8, FieldError>
Get the beam control field (bits 6-5 of beam/sequence byte).
Sourcepub fn set_beam_control(
&self,
buf: &mut [u8],
value: u8,
) -> Result<(), FieldError>
pub fn set_beam_control( &self, buf: &mut [u8], value: u8, ) -> Result<(), FieldError>
Set the beam control field (bits 6-5 of beam/sequence byte).
Sourcepub fn seqn(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn seqn(&self, buf: &[u8]) -> Result<u8, FieldError>
Get the sequence number (bits 3-0 of beam/sequence byte).
Sourcepub fn set_seqn(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
pub fn set_seqn(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
Set the sequence number (bits 3-0 of beam/sequence byte).
Sourcepub fn set_length(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
pub fn set_length(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
Set the length field at offset 7.
Sourcepub fn dst(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn dst(&self, buf: &[u8]) -> Result<u8, FieldError>
Read the destination node ID at offset 8.
Sourcepub fn set_dst(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
pub fn set_dst(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
Set the destination node ID at offset 8.
Sourcepub fn crc(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn crc(&self, buf: &[u8]) -> Result<u8, FieldError>
Read the CRC byte. For ACK frames it is at offset 9. For REQ frames it is the last byte of the frame.
Sourcepub fn set_crc(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
pub fn set_crc(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
Set the CRC byte (last byte of the frame).
Sourcepub fn is_ack(&self, buf: &[u8]) -> bool
pub fn is_ack(&self, buf: &[u8]) -> bool
Returns true if this frame is an ACK (no payload – total length is 10).
Sourcepub fn cmd_class(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn cmd_class(&self, buf: &[u8]) -> Result<u8, FieldError>
Read the command class byte at offset 9 (only valid for Req frames). In the wire format, the payload starts at offset 9 (between dst and crc). Layout for Req: [homeId(4), src(1), fc(1), bs(1), len(1), dst(1), cmdClass(1), cmd(1), …data, crc(1)]
Sourcepub fn set_cmd_class(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
pub fn set_cmd_class(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
Set the command class byte at offset 9.
Sourcepub fn cmd(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn cmd(&self, buf: &[u8]) -> Result<u8, FieldError>
Read the command byte at offset 10 (only valid for Req frames with sufficient payload).
Sourcepub fn set_cmd(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
pub fn set_cmd(&self, buf: &mut [u8], value: u8) -> Result<(), FieldError>
Set the command byte at offset 10.
Sourcepub fn cmd_data<'a>(&self, buf: &'a [u8]) -> Result<&'a [u8], FieldError>
pub fn cmd_data<'a>(&self, buf: &'a [u8]) -> Result<&'a [u8], FieldError>
Read the command data bytes (everything after cmd and before CRC).
Sourcepub fn verify_crc(&self, buf: &[u8]) -> bool
pub fn verify_crc(&self, buf: &[u8]) -> bool
Verify the CRC of this frame. Computes XOR of all bytes except the last (starting from 0xFF) and compares with the stored CRC.
Sourcepub fn field_names() -> &'static [&'static str]
pub fn field_names() -> &'static [&'static str]
Get the field names for this layer.
Sourcepub fn get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
pub fn get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Get a field value by name.
Sourcepub fn set_field(
&self,
buf: &mut [u8],
name: &str,
value: FieldValue,
) -> Option<Result<(), FieldError>>
pub fn set_field( &self, buf: &mut [u8], name: &str, value: FieldValue, ) -> Option<Result<(), FieldError>>
Set a field value by name.
Trait Implementations§
Source§impl Clone for ZWaveLayer
impl Clone for ZWaveLayer
Source§fn clone(&self) -> ZWaveLayer
fn clone(&self) -> ZWaveLayer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ZWaveLayer
impl Debug for ZWaveLayer
Source§impl From<ZWaveLayer> for LayerEnum
impl From<ZWaveLayer> for LayerEnum
Source§fn from(v: ZWaveLayer) -> LayerEnum
fn from(v: ZWaveLayer) -> LayerEnum
Source§impl Layer for ZWaveLayer
impl Layer for ZWaveLayer
Source§fn header_len(&self, data: &[u8]) -> usize
fn header_len(&self, data: &[u8]) -> usize
Source§fn field_names(&self) -> &'static [&'static str]
fn field_names(&self) -> &'static [&'static str]
Source§impl LayerDispatch for ZWaveLayer
impl LayerDispatch for ZWaveLayer
Source§fn dispatch_kind(&self) -> LayerKind
fn dispatch_kind(&self) -> LayerKind
Source§fn dispatch_index(&self) -> &LayerIndex
fn dispatch_index(&self) -> &LayerIndex
Source§fn dispatch_summary(&self, buf: &[u8]) -> String
fn dispatch_summary(&self, buf: &[u8]) -> String
Source§fn dispatch_header_len(&self, buf: &[u8]) -> usize
fn dispatch_header_len(&self, buf: &[u8]) -> usize
Source§fn dispatch_field_names(&self) -> &'static [&'static str]
fn dispatch_field_names(&self) -> &'static [&'static str]
Source§fn dispatch_get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
fn dispatch_get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Source§fn dispatch_set_field(
&self,
buf: &mut [u8],
name: &str,
value: FieldValue,
) -> Option<Result<(), FieldError>>
fn dispatch_set_field( &self, buf: &mut [u8], name: &str, value: FieldValue, ) -> Option<Result<(), FieldError>>
Auto Trait Implementations§
impl Freeze for ZWaveLayer
impl RefUnwindSafe for ZWaveLayer
impl Send for ZWaveLayer
impl Sync for ZWaveLayer
impl Unpin for ZWaveLayer
impl UnsafeUnpin for ZWaveLayer
impl UnwindSafe for ZWaveLayer
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more