pub struct Action<'a> {
pub data: ActionData,
/* private fields */
}
Expand description
A Quick Action setup in the Hive account.
Fields§
§data: ActionData
Implementations§
Source§impl Action<'_>
impl Action<'_>
Sourcepub async fn activate(&self) -> Result<bool, ApiError>
pub async fn activate(&self) -> Result<bool, ApiError>
Activate the Quick Actions.
§Examples
use hive_client::authentication::{TrustedDevice, User};
let client = hive_client::Client::new("Home Automation").await;
let trusted_device = Some(TrustedDevice::new(
"device_password",
"device_group_key",
"device_key"
));
client.login(User::new("example@example.com", "example", trusted_device))
.await
.expect("Login should succeed");
let actions = client.get_actions()
.await
.expect("Quick action should be retrieved");
// Activate a quick action
let mut turn_off_heating = actions.into_iter()
.find(|action| action.data.id == "1234-5678-000-0000")
.expect("Quick action to turn off heating should exist");
let activated = turn_off_heating.activate().await;
assert!(activated.is_ok());
§Errors
Returns an error if the Quick Actions could not be activated.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Action<'a>
impl<'a> !RefUnwindSafe for Action<'a>
impl<'a> Send for Action<'a>
impl<'a> Sync for Action<'a>
impl<'a> Unpin for Action<'a>
impl<'a> !UnwindSafe for Action<'a>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.