use crate::error::{ErpcResult, TransportError};
use async_trait::async_trait;
use std::time::Duration;
#[async_trait]
pub trait Transport: Send + Sync {
async fn send(&mut self, data: &[u8]) -> ErpcResult<()>;
async fn receive(&mut self) -> ErpcResult<Vec<u8>>;
async fn close(&mut self) -> ErpcResult<()>;
fn is_connected(&self) -> bool;
fn set_timeout(&mut self, timeout: Duration);
}
#[async_trait]
pub trait TransportFactory: Send + Sync {
type Transport: Transport;
async fn create(&self) -> ErpcResult<Self::Transport>;
}
pub mod framed;
pub mod memory;
pub mod rusb;
pub mod serial;
#[cfg(unix)]
pub mod socket;
pub mod tcp;
#[cfg(feature = "tcp")]
pub use tcp::TcpTransport;
#[cfg(feature = "serial")]
pub use serial::SerialTransport;
#[cfg(unix)]
pub use socket::SocketTransport;
pub use framed::FramedTransport;
pub use memory::MemoryTransport;