pub mod common;
pub mod error;
pub mod reader;
#[cfg(feature = "test-helpers")]
pub mod test_helpers;
pub mod traits;
#[macro_export]
macro_rules! impl_from_io_error {
($($ty:ty),+ $(,)?) => {
$( $crate::impl_from_io_error!($ty => StdIOError); )+
};
($ty:ty => $variant:ident) => {
#[automatically_derived]
impl From<std::io::Error> for $ty {
fn from(err: std::io::Error) -> Self {
<$ty>::$variant(err.to_string().into())
}
}
};
}
#[allow(clippy::len_without_is_empty)]
pub trait WritablePdu<ErrorType> {
const BASE_LENGTH: usize;
fn len(&self) -> usize;
fn write<T: std::io::Write>(&self, _writer: &mut T) -> Result<(), ErrorType>
where
Self: Sized;
}
#[allow(clippy::len_without_is_empty)]
pub trait WritablePduWithOneInput<I, ErrorType> {
const BASE_LENGTH: usize;
fn len(&self, input: I) -> usize;
fn write<T: std::io::Write>(&self, _writer: &mut T, input: I) -> Result<(), ErrorType>
where
Self: Sized;
}
#[allow(clippy::len_without_is_empty)]
pub trait WritablePduWithTwoInputs<I1, I2, ErrorType> {
const BASE_LENGTH: usize;
fn len(&self, input1: I1, input2: I2) -> usize;
fn write<T: std::io::Write>(
&self,
_writer: &mut T,
input1: I1,
input2: I2,
) -> Result<(), ErrorType>
where
Self: Sized;
}