pub struct PacketBuilder {
pub addr: Address,
pub ctrl: ControlByte,
pub scb: Option<Scb>,
pub code: u8,
pub data: Vec<u8>,
}Expand description
Builder for a single OSDP packet.
Caller fills in the high-level fields and calls
PacketBuilder::encode (for non-secure packets) or
PacketBuilder::encode_with_mac (for SCS_15..=SCS_18) to produce
the bytes ready for transmission.
Fields§
§addr: AddressAddress byte (with reply flag if PD → ACU).
ctrl: ControlByteCTRL byte (SQN + flags).
scb: Option<Scb>Security Control Block (None if CTRL.HAS_SCB is clear).
code: u8Command or reply code byte.
data: Vec<u8>DATA payload (already encrypted, if SCS_17/18).
Implementations§
Source§impl PacketBuilder
impl PacketBuilder
Sourcepub fn plain(addr: Address, ctrl: ControlByte, code: u8, data: Vec<u8>) -> Self
pub fn plain(addr: Address, ctrl: ControlByte, code: u8, data: Vec<u8>) -> Self
Build a packet with neither SCB nor MAC.
Sourcepub fn encode(&self) -> Result<Vec<u8>, Error>
pub fn encode(&self) -> Result<Vec<u8>, Error>
Encode the packet without any MAC.
If the CTRL byte has crate::packet::CtrlFlags::HAS_SCB set
but the SCB type would require a MAC, the caller must use
Self::encode_with_mac instead.
Trait Implementations§
Source§impl Clone for PacketBuilder
impl Clone for PacketBuilder
Source§fn clone(&self) -> PacketBuilder
fn clone(&self) -> PacketBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PacketBuilder
impl RefUnwindSafe for PacketBuilder
impl Send for PacketBuilder
impl Sync for PacketBuilder
impl Unpin for PacketBuilder
impl UnsafeUnpin for PacketBuilder
impl UnwindSafe for PacketBuilder
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
Mutably borrows from an owned value. Read more