pub enum ControlCommand {
Scan {
code: String,
terminator: Option<Terminator>,
delay_ms: Option<u64>,
},
Tap {
uid: String,
records: Option<Vec<NdefRecord>>,
},
NfcWrite {
records: Vec<NdefRecord>,
overwrite: bool,
},
NfcMakeReadOnly,
CloseDrawer,
Custom {
name: String,
payload: Value,
},
}Expand description
A control action sent to a device: by a person, test or agent (scan, tap, close drawer), or by the app through a browser API that does not carry bytes (an NFC write).
use hardless_core::ControlCommand;
let cmd: ControlCommand =
serde_json::from_str(r#"{ "type": "scan", "code": "4006381333931" }"#).unwrap();
assert!(matches!(cmd, ControlCommand::Scan { .. }));Variants§
Scan
Scan a barcode (POST /devices/:id/scan).
Fields
§
terminator: Option<Terminator>Overrides the device’s terminator.
Tap
Tap an NFC card (POST /devices/:id/tap).
Fields
§
records: Option<Vec<NdefRecord>>The card’s NDEF records. Without them the reader uses what it remembers of this card (including anything the app wrote to it), or an empty card.
NfcWrite
The app writes records to the card on the reader (NDEFReader.write()).
Fields
§
records: Vec<NdefRecord>The records to write.
NfcMakeReadOnly
The app makes the card on the reader read-only (NDEFReader.makeReadOnly()).
CloseDrawer
Close an open cash drawer by hand.
Custom
A device-specific command for plugins.
Trait Implementations§
Source§impl Clone for ControlCommand
impl Clone for ControlCommand
Source§impl Debug for ControlCommand
impl Debug for ControlCommand
Source§impl<'de> Deserialize<'de> for ControlCommand
impl<'de> Deserialize<'de> for ControlCommand
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ControlCommand
impl PartialEq for ControlCommand
Source§impl Serialize for ControlCommand
impl Serialize for ControlCommand
impl StructuralPartialEq for ControlCommand
Auto Trait Implementations§
impl Freeze for ControlCommand
impl RefUnwindSafe for ControlCommand
impl Send for ControlCommand
impl Sync for ControlCommand
impl Unpin for ControlCommand
impl UnsafeUnpin for ControlCommand
impl UnwindSafe for ControlCommand
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