#[repr(u8)]pub enum Command {
DpRead = 0,
DpWrite = 1,
ApRead = 2,
ApWrite = 3,
ApBulkRead = 18,
ApBulkWrite = 19,
MultiRegWrite = 20,
Ping = 240,
ResetTarget = 241,
Clock = 242,
SetSpeed = 243,
Disconnect = 255,
}Expand description
Binary API single byte command codes
Variants§
DpRead = 0
DpWrite = 1
ApRead = 2
ApWrite = 3
ApBulkRead = 18
ApBulkWrite = 19
MultiRegWrite = 20
Ping = 240
ResetTarget = 241
Clock = 242
SetSpeed = 243
Disconnect = 255
Implementations§
Source§impl Command
impl Command
Sourcepub fn to_byte(self) -> u8
pub fn to_byte(self) -> u8
Converts a Command to its byte representation
Returns:
u8: The byte representation of the command.
Sourcepub fn from_byte(cmd: u8) -> Result<Self, ProtocolError>
pub fn from_byte(cmd: u8) -> Result<Self, ProtocolError>
Convert a command byte to a Command enum variant
Arguments:
cmd: The command byte to convert.
Returns:
Ok(Command): If the command byte is recognized.Err(ProtocolError::Command): If the command byte is not recognized.
Sourcepub fn remaining_bytes(&self) -> Result<(usize, bool), ProtocolError>
pub fn remaining_bytes(&self) -> Result<(usize, bool), ProtocolError>
Determine how many more bytes to read for this command type
Returns:
Ok((usize, bool)): The number of bytes needed and whether the command will receive additional data (i.e. is a bulk command).Err(SwdError::Api): If the command is not recognized.
Sourcepub fn var_bytes(&self, count: u16) -> Result<usize, ProtocolError>
pub fn var_bytes(&self, count: u16) -> Result<usize, ProtocolError>
Determines how many variable bytes this command requires
Arguments:
count: The number of words to read for bulk commands.
Returns:
Ok(usize): The number of bytes to read for the command.Err(SwdError::Api): If the command is not recognized or if the count is invalid.
Trait Implementations§
impl Copy for Command
impl Eq for Command
impl StructuralPartialEq for Command
Auto Trait Implementations§
impl Freeze for Command
impl RefUnwindSafe for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl UnsafeUnpin for Command
impl UnwindSafe for Command
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