pub enum Command {
WriteParameter {
address: Address,
value: u8,
},
ReadParameter {
address: Address,
size: u32,
},
GetVersion,
}Expand description
Command types for VR-6HD
Variants§
WriteParameter
Write parameter (DTH)
ReadParameter
Read parameter (RQH)
GetVersion
Get version information (VER)
Implementations§
Source§impl Command
impl Command
Sourcepub fn encode(&self) -> String
pub fn encode(&self) -> String
Encode command to string format
For Telnet, STX (0x02) is optional and omitted here. For RS-232, STX should be prepended by the transport layer.
Requires alloc for String allocation.
Examples found in repository?
examples/telnet_client.rs (line 86)
84 pub fn send_command(&mut self, command: &Command) -> Result<Response, TelnetError> {
85 // Encode command (without STX for Telnet)
86 let cmd_str = command.encode();
87 let cmd_bytes = cmd_str.as_bytes();
88
89 // Send command
90 self.stream.write_all(cmd_bytes)?;
91 self.stream.flush()?;
92
93 // Read response
94 self.read_response()
95 }Sourcepub fn encode_with_stx(&self) -> String
pub fn encode_with_stx(&self) -> String
Encode command with STX prefix (for RS-232)
Requires alloc for String allocation.
Sourcepub fn write<W: Write>(&self, w: &mut W) -> Result
pub fn write<W: Write>(&self, w: &mut W) -> Result
Write command to a formatter
This method doesn’t require alloc and can be used in no_std environments
without heap allocation.
Sourcepub fn write_with_stx<W: Write>(&self, w: &mut W) -> Result
pub fn write_with_stx<W: Write>(&self, w: &mut W) -> Result
Write command with STX prefix to a formatter
Trait Implementations§
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 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