pub struct CommandRequest {
pub command: String,
pub parameter: String,
pub command_type: String,
}
Expand description
A command request to send to the SwitchBot API.
For more details of each field, please refer to the SwitchBot documentation about device control commands.
§Examples
let command = CommandRequest {
command: "turnOn".into(),
..Default::default()
};
Fields§
§command: String
The command.
parameter: String
The command parameters.
The default value is default
.
command_type: String
The command type.
The default value is command
.
Trait Implementations§
Source§impl Debug for CommandRequest
impl Debug for CommandRequest
Source§impl Default for CommandRequest
impl Default for CommandRequest
Source§impl From<&str> for CommandRequest
impl From<&str> for CommandRequest
Source§fn from(text: &str) -> Self
fn from(text: &str) -> Self
Parse a string into a CommandRequest
.
Please see the switchbot-cli
document for the syntax.
assert_eq!(
CommandRequest::from("turnOn"),
CommandRequest {
command: "turnOn".into(),
..Default::default()
}
);
assert_eq!(
CommandRequest::from("turnOn:parameter:colon/slash"),
CommandRequest {
command: "turnOn".into(),
parameter: "parameter:colon/slash".into(),
..Default::default()
}
);
assert_eq!(
CommandRequest::from("customize/turnOn"),
CommandRequest {
command: "turnOn".into(),
command_type: "customize".into(),
..Default::default()
}
);
assert_eq!(
CommandRequest::from("customize/turnOn:parameter:colon/slash"),
CommandRequest {
command: "turnOn".into(),
command_type: "customize".into(),
parameter: "parameter:colon/slash".into(),
}
);
Source§impl PartialEq for CommandRequest
impl PartialEq for CommandRequest
Source§impl Serialize for CommandRequest
impl Serialize for CommandRequest
impl StructuralPartialEq for CommandRequest
Auto Trait Implementations§
impl Freeze for CommandRequest
impl RefUnwindSafe for CommandRequest
impl Send for CommandRequest
impl Sync for CommandRequest
impl Unpin for CommandRequest
impl UnwindSafe for CommandRequest
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