AirTouch5

Struct AirTouch5 

Source
pub struct AirTouch5 { /* private fields */ }
Expand description

An AirTouch 5 console that we are interacting with.

This is the primary structure for interacting with the console. See the crate-level docs for usage and examples.

Implementations§

Source§

impl AirTouch5

Source

pub async fn with_ipaddr(addr: IpAddr) -> Result<Self>

Connect to an AirTouch 5 console at the given IP address.

let console_addr = IpAddr::V4(Ipv4Addr::new(192, 0, 2, 123));
let at5 = AirTouch5::with_ipaddr(console_addr).await?;
Source

pub fn subscribe_changes(&self) -> Option<Receiver<StatusChange>>

Returns a receiver for a broadcast channel, whose values represent asynchronous updates to the current system state. Each update may be for or more AC units, or for one or more zones.

let at5 = AirTouch5::with_ipaddr(console_addr).await?;
if let Some(mut changes) = at5.subscribe_changes() {
    let change = changes.recv().await?;
    match change {
        StatusChange::AcStatusChange(acs) => {
            // handle the new AC state(s)
        },
        StatusChange::ZoneStatusChange(zones) => {
            // handle the new zone state(s)
        },
        _ => {
            // a change other than AC or zone state;
            // reserved for future use
        },
    }
}

None may be returned if the channel has already been closed (for example, if the connection has been lost).

Source

pub fn subscribe_status(&self) -> Option<Receiver<CurrentStatus>>

Returns a recevier for a watch channel, whose value represents the current known state of the system.

let at5 = AirTouch5::with_ipaddr(console_addr).await?;
if let Some(mut watch) = at5.subscribe_status() {
    let current = watch.borrow_and_update();
    println!("{} AC units and {} zones are on",
        current.acs().values()
            .filter(|a| a.power.is_some() && a.power != Some(AcPower::Off))
            .count(),
        current.zones().values()
            .filter(|z| z.power != ZonePower::Off)
            .count(),
    );
}

None may be returned if the channel has already been closed (for example, if the connection has been lost).

Note that when a connection is first established, until a full set of status messages has been received, the state is not fully known, and only the known state will be represented by the channel value.

Calling both ac_status() and zone_status() will ensure that the state is fully known.

let at5 = AirTouch5::with_ipaddr(console_addr).await?;
let _ = at5.ac_status().await?;
let _ = at5.zone_status().await?;
let mut watch = at5.subscribe_status();
Source

pub async fn shutdown(&mut self) -> Result<()>

Gracefully shut down the connection to the console.

Source

pub async fn zone_status(&self) -> Result<ZoneStatusMessage>

Request the current status of all zones.

Source

pub async fn zone_status_timeout( &self, duration: Duration, ) -> Result<ZoneStatusMessage>

Request the current status of all zones, with timeout.

Source

pub async fn ac_status(&self) -> Result<AcStatusMessage>

Request the current status of all AC units.

Source

pub async fn ac_status_timeout( &self, duration: Duration, ) -> Result<AcStatusMessage>

Request the current status of all AC units, with timeout.

Source

pub async fn ac_capabilities(&self) -> Result<AcCapabilityResponse>

Request the capabilities of all AC units.

Source

pub async fn ac_capabilities_timeout( &self, duration: Duration, ) -> Result<AcCapabilityResponse>

Request the capabilities of all AC units, with timeout.

Source

pub async fn ac_capability(&self, ac_index: u8) -> Result<AcCapability>

Request the capabilities of a specific AC unit.

Source

pub async fn ac_capability_timeout( &self, ac_index: u8, duration: Duration, ) -> Result<AcCapability>

Request the capabilities of a specific AC unit, with timeout.

Source

pub async fn console_version(&self) -> Result<ConsoleVersionResponse>

Request the version information of the AirTouch 5 system.

Source

pub async fn console_version_timeout( &self, duration: Duration, ) -> Result<ConsoleVersionResponse>

Request the version information of the AirTouch 5 system, with timeout.

Source

pub async fn zone_names(&self) -> Result<ZoneNameResponse>

Request the names of all zones.

Source

pub async fn zone_names_timeout( &self, duration: Duration, ) -> Result<ZoneNameResponse>

Request the names of all zones, with timeout.

Source

pub async fn zone_name(&self, zone_idx: u8) -> Result<String>

Request the name of a specific zone.

Source

pub async fn zone_name_timeout( &self, zone_idx: u8, duration: Duration, ) -> Result<String>

Request the name of a specific zone, with timeout.

Trait Implementations§

Source§

impl Drop for AirTouch5

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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, U> Into<U> for T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.