use crate::common::Message;
use std::error::Error;
#[doc(hidden)]
#[cfg(feature = "dbus")]
pub mod dbus;
#[cfg(feature = "websockets-json")]
pub mod websockets_json;
pub trait S2Transport {
type TransportError: Error;
fn send(&mut self, message: Message) -> impl Future<Output = Result<(), Self::TransportError>> + Send;
fn receive(&mut self) -> impl Future<Output = Result<Message, Self::TransportError>> + Send;
fn disconnect(self) -> impl Future<Output = ()> + Send;
}
#[doc(hidden)]
pub mod test {
use std::convert::Infallible;
use crate::{connection::S2Connection, frbc::StorageStatus};
use super::*;
pub struct MockTransport;
impl MockTransport {
pub fn new_connection() -> S2Connection<Self> {
S2Connection::new(MockTransport)
}
}
impl S2Transport for MockTransport {
type TransportError = Infallible;
async fn send(&mut self, _: Message) -> Result<(), Self::TransportError> {
Ok(())
}
async fn receive(&mut self) -> Result<Message, Self::TransportError> {
Ok(Message::FrbcStorageStatus(StorageStatus::new(0.0)))
}
async fn disconnect(self) {}
}
}