use thiserror::Error;
use tokio::io::{AsyncRead, AsyncWrite};
use tokio_util::codec::Framed;
pub mod client;
pub mod codec;
pub mod headers;
pub mod packet;
pub mod server;
pub use codec::ObexCodec;
#[derive(Debug, Error)]
pub enum TransportError {
#[error("I/O: {0}")]
Io(#[from] std::io::Error),
#[error("declared packet length {declared} is below the 3-byte OBEX minimum")]
InvalidLength {
declared: usize,
},
#[error("unexpected end of stream")]
UnexpectedEof,
#[error("transport driver: {0}")]
External(String),
}
pub type ObexTransport<T> = Framed<T, ObexCodec>;
pub fn wrap<T: AsyncRead + AsyncWrite>(inner: T) -> ObexTransport<T> {
Framed::new(inner, ObexCodec)
}