use core::future::Future;
use crate::error::Error;
use crate::frame::parameters::wwah::{
get_parent_classification_enabled, is_hub_connected, is_uptime_long, set_hub_connectivity,
set_long_uptime, set_parent_classification_enabled,
};
use crate::transport::Transport;
pub trait Wwah {
fn get_parent_classification_enabled(&mut self) -> impl Future<Output = Result<bool, Error>>;
fn is_hub_connected(&mut self) -> impl Future<Output = Result<bool, Error>>;
fn is_uptime_long(&mut self) -> impl Future<Output = Result<bool, Error>>;
fn set_hub_connectivity(&mut self, connected: bool) -> impl Future<Output = Result<(), Error>>;
fn set_long_uptime(&mut self, has_long_uptime: bool)
-> impl Future<Output = Result<(), Error>>;
fn set_parent_classification_enabled(
&mut self,
enabled: bool,
) -> impl Future<Output = Result<(), Error>>;
}
impl<T> Wwah for T
where
T: Transport,
{
async fn get_parent_classification_enabled(&mut self) -> Result<bool, Error> {
self.communicate(get_parent_classification_enabled::Command)
.await
.map(Into::into)
}
async fn is_hub_connected(&mut self) -> Result<bool, Error> {
self.communicate(is_hub_connected::Command)
.await
.map(Into::into)
}
async fn is_uptime_long(&mut self) -> Result<bool, Error> {
self.communicate(is_uptime_long::Command)
.await
.map(Into::into)
}
async fn set_hub_connectivity(&mut self, connected: bool) -> Result<(), Error> {
self.communicate(set_hub_connectivity::Command::new(connected))
.await
.map(drop)
}
async fn set_long_uptime(&mut self, has_long_uptime: bool) -> Result<(), Error> {
self.communicate(set_long_uptime::Command::new(has_long_uptime))
.await
.map(drop)
}
async fn set_parent_classification_enabled(&mut self, enabled: bool) -> Result<(), Error> {
self.communicate(set_parent_classification_enabled::Command::new(enabled))
.await
.map(drop)
}
}