use super::adapter::Adapter;
use crate::{Result, api};
use async_trait::async_trait;
use std::future::IntoFuture;
use windows::Devices::Radios::{Radio, RadioKind};
#[derive(Clone, Debug)]
pub struct Manager {}
impl Manager {
pub async fn new() -> Result<Self> {
Ok(Self {})
}
}
#[async_trait]
impl api::Manager for Manager {
type Adapter = Adapter;
async fn adapters(&self) -> Result<Vec<Adapter>> {
let radios = Radio::GetRadiosAsync()?.into_future().await?;
radios
.into_iter()
.filter(|radio| radio.Kind() == Ok(RadioKind::Bluetooth))
.map(|radio| Adapter::new(radio))
.collect()
}
}