use super::types::{AdvertisingConfig, PeripheralEvent};
use crate::error::BlewResult;
use crate::gatt::service::GattService;
use crate::l2cap::{L2capChannel, types::Psm};
use crate::types::DeviceId;
use futures_core::Stream;
use std::future::Future;
use uuid::Uuid;
pub(crate) mod private {
pub trait Sealed {}
}
pub trait PeripheralBackend: private::Sealed + Send + Sync + 'static {
type EventStream: Stream<Item = PeripheralEvent> + Send + Unpin + 'static;
fn new() -> impl Future<Output = BlewResult<Self>> + Send
where
Self: Sized;
fn is_powered(&self) -> impl Future<Output = BlewResult<bool>> + Send;
fn add_service(&self, service: &GattService) -> impl Future<Output = BlewResult<()>> + Send;
fn start_advertising(
&self,
config: &AdvertisingConfig,
) -> impl Future<Output = BlewResult<()>> + Send;
fn stop_advertising(&self) -> impl Future<Output = BlewResult<()>> + Send;
fn notify_characteristic(
&self,
device_id: &DeviceId,
char_uuid: Uuid,
value: Vec<u8>,
) -> impl Future<Output = BlewResult<()>> + Send;
fn l2cap_listener(
&self,
) -> impl Future<
Output = BlewResult<(
Psm,
impl Stream<Item = BlewResult<(DeviceId, L2capChannel)>> + Send + 'static,
)>,
> + Send;
fn events(&self) -> Self::EventStream;
}