pub struct SwitchBot { /* private fields */ }
Expand description
Represents a SwitchBot API server.
Implementations§
Source§impl SwitchBot
impl SwitchBot
Sourcepub fn new_with_authentication(token: &str, secret: &str) -> Self
pub fn new_with_authentication(token: &str, secret: &str) -> Self
Construct a new instance with the authentication information.
Please refer to the SwitchBot documentation about how to obtain the token and secret key.
This function is equivalent to:
let mut switch_bot = SwitchBot::new();
switch_bot.set_authentication(token, secret);
Sourcepub fn new_for_test(num_devices: usize) -> Self
pub fn new_for_test(num_devices: usize) -> Self
Construct an instance for testing. The instance has the specified number of devices for testing.
Sourcepub fn set_authentication(&mut self, token: &str, secret: &str)
pub fn set_authentication(&mut self, token: &str, secret: &str)
Set the authentication information.
Please refer to the SwitchBot documentation about how to obtain the token and secret key.
Sourcepub fn devices(&self) -> &DeviceList
pub fn devices(&self) -> &DeviceList
Returns a list of Device
s.
This list is empty initially.
Call SwitchBot::load_devices()
to populate the list.
Sourcepub async fn load_devices(&mut self) -> Result<()>
pub async fn load_devices(&mut self) -> Result<()>
Load the device list from the SwitchBot API.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SwitchBot
impl !RefUnwindSafe for SwitchBot
impl Send for SwitchBot
impl Sync for SwitchBot
impl Unpin for SwitchBot
impl !UnwindSafe for SwitchBot
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