pub struct Protocol { /* private fields */ }Expand description
Transport-agnostic protocol handler
This handles protocol parsing and command buffering. It does NOT handle transport connection/disconnection.
Implementations§
Source§impl Protocol
impl Protocol
Sourcepub fn device_name(&self) -> &str
pub fn device_name(&self) -> &str
Get device name
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if connected (application-managed)
Sourcepub fn set_connected(&mut self, connected: bool)
pub fn set_connected(&mut self, connected: bool)
Set connection status (called by application)
Sourcepub fn process_received_data(&mut self, data: &[u8])
pub fn process_received_data(&mut self, data: &[u8])
Process incoming data from transport layer
This appends data to the internal buffer for parsing.
Call receive_command() to extract parsed commands.
Transport Independence: This method accepts bytes from ANY source:
- BLE notification data
- USB CDC read buffer
- UART RX buffer
- WiFi socket data
Sourcepub fn receive_command(&mut self) -> Option<Command>
pub fn receive_command(&mut self) -> Option<Command>
Parse and consume the next command from the buffer
Returns Some(Command) if a complete, valid command was parsed.
Returns None if buffer is empty or packet is incomplete/invalid.
Sourcepub fn get_capabilities_data(&self, caps: &str) -> Vec<u8, 256>
pub fn get_capabilities_data(&self, caps: &str) -> Vec<u8, 256>
Format capabilities JSON into byte buffer
Example capabilities string:
{
"sensors": {"accel": true, "mag": true},
"gpio": {"digital": 8, "pwm": 8},
"display": {"matrix": true}
}Auto Trait Implementations§
impl Freeze for Protocol
impl RefUnwindSafe for Protocol
impl Send for Protocol
impl Sync for Protocol
impl Unpin for Protocol
impl UnwindSafe for Protocol
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