#[macro_use]
extern crate log;
#[macro_use]
extern crate anyhow;
use async_trait::async_trait;
use bytes::Bytes;
use futures::Stream;
use std::pin::Pin;
pub mod constraint;
pub mod das;
pub mod dds;
pub mod dods;
pub mod hyperslab;
pub use constraint::Constraint;
pub use das::Das;
pub use dds::Dds;
pub use dods::Dods;
#[async_trait]
pub trait Dap2 {
async fn das(&self) -> &Das;
async fn dds(&self) -> &Dds;
async fn variable(
&self,
variable: &dds::DdsVariableDetails,
) -> Result<
Pin<Box<dyn Stream<Item = Result<Bytes, anyhow::Error>> + Send + 'static>>,
anyhow::Error,
>;
async fn raw(
&self,
) -> Result<
(
u64,
Pin<Box<dyn Stream<Item = Result<Bytes, std::io::Error>> + Send + 'static>>,
),
std::io::Error,
>;
}
#[async_trait]
impl<T: Send + Sync + Dap2> Dap2 for std::sync::Arc<T> {
async fn das(&self) -> &Das {
T::das(self).await
}
async fn dds(&self) -> &Dds {
T::dds(self).await
}
async fn variable(
&self,
variable: &dds::DdsVariableDetails,
) -> Result<
Pin<Box<dyn Stream<Item = Result<Bytes, anyhow::Error>> + Send + 'static>>,
anyhow::Error,
> {
T::variable(self, variable).await
}
async fn raw(
&self,
) -> Result<
(
u64,
Pin<Box<dyn Stream<Item = Result<Bytes, std::io::Error>> + Send + 'static>>,
),
std::io::Error,
> {
T::raw(self).await
}
}