Struct govee_api::GoveeClient

source ·
pub struct GoveeClient { /* private fields */ }
Expand description

A client for interacting with Govee devices through their API.

This struct provides methods to control Govee devices using the Govee API. It requires a valid Govee API key and root URL to initialize.

Implementations§

source§

impl GoveeClient

Controls a Govee device using the provided payload.

This method sends a PUT request to the Govee API to control a device with the specified payload. The payload should be in the form of a PayloadBody struct.

Arguments

  • payload - The payload containing the control instructions for the device.

Panics

This method will panic if the PUT request encounters an error.

source

pub async fn control_device(&self, payload: PayloadBody)

source§

impl GoveeClient

Controls a Govee appliance using the provided payload.

This method sends a PUT request to the Govee API to control an appliance with the specified payload. The payload should be in the form of a PayloadBody struct.

Arguments

  • payload - The payload containing the control instructions for the appliance.

Panics

This method will panic if the PUT request encounters an error.

source

pub async fn control_appliance(&self, payload: PayloadBody)

source§

impl GoveeClient

Retrieves a list of Govee devices.

This method sends a GET request to the Govee API to retrieve a list of devices associated with the Govee account.

Returns

An ApiResponseGoveeDevices containing information about the devices.

Panics

This method will panic if the GET request encounters an error.

source§

impl GoveeClient

Retrieves a list of Govee appliances.

This method sends a GET request to the Govee API to retrieve a list of appliances associated with the Govee account.

Returns

An ApiResponseGoveeAppliances containing information about the appliances.

Panics

This method will panic if the GET request encounters an error.

source§

impl GoveeClient

Retrieves the state of a Govee device.

This method sends a GET request to the Govee API to retrieve the state of a specific device.

Arguments

  • device - The device ID or name.
  • model - The model of the device.

Returns

An ApiResponseGoveeDeviceState containing the current state of the device.

Panics

This method will panic if the GET request encounters an error.

source

pub async fn get_device_state( &self, device: &str, model: &str ) -> ApiResponseGoveeDeviceState

source§

impl GoveeClient

source

pub fn new(api_key: &str) -> GoveeClient

Creates a new instance of the GoveeClient with the specified API key and root URL.

Arguments
  • govee_api_key - A valid Govee API key for authentication.
  • govee_root_url - The root URL of the Govee API.
Returns

A new GoveeClient instance.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more