use std::sync::Arc;
use crate::endpoint::polled_audio_driver::PolledAudioEndpointFactory;
pub use crate::endpoint::polled_audio_driver::{
PolledAudioEndpointConfig, PolledAudioEndpointConfigError, PolledAudioReceipt,
};
use crate::endpoint::EndpointDriverFactory;
pub const POLLED_AUDIO_OPERATOR_ID: &str = "io.pocketstation.endpoint.polled-audio.v1";
pub struct PolledAudioEndpoint {
factory: Arc<PolledAudioEndpointFactory>,
receipt: PolledAudioReceipt,
}
impl PolledAudioEndpoint {
pub fn new(config: PolledAudioEndpointConfig) -> Result<Self, PolledAudioEndpointConfigError> {
let (factory, receipt) = PolledAudioEndpointFactory::new(config)?;
Ok(Self {
factory: Arc::new(factory),
receipt,
})
}
pub fn receipt(&self) -> PolledAudioReceipt {
self.receipt.clone()
}
pub(crate) fn factory(&self) -> Arc<dyn EndpointDriverFactory> {
self.factory.clone()
}
}