impl SlipMime for Mime2Slip { const CONV_TO: Option<bool> = Some(false); }
impl SlipMime for SlipNoConv { const CONV_TO: Option<bool> = None; }
-#[derive(Debug)]
-#[derive(Error)]
-#[error("only bad IP datagrams")]
-pub struct ErrorOnlyBad;
-
-#[throws(ErrorOnlyBad)]
-pub fn checkn<AC, EH, OUT, ACR, M: SlipMime+Copy>(
+#[derive(Debug,Error)]
+pub enum SlipFramesError<E> where E: std::error::Error + 'static {
+ #[error("only bad IP datagrams")] ErrorOnlyBad,
+ #[error("{0}")] Other(#[from] E),
+}
+
+#[throws(SlipFramesError<EHE>)]
+pub fn checkn<AC, EH, EHE, OUT, ACR, M: SlipMime+Copy>(
mime: M,
mtu: u32,
data: &[u8],
mut error_handler: EH
) where AC: Fn(&[u8]) -> Result<ACR, PacketError> + Copy,
OUT: FnMut((Box<[u8]>, ACR)) -> Result<(), PacketError>,
- EH: FnMut(PacketError),
+ EH: FnMut(PacketError) -> Result<(), SlipFramesError<EHE>>,
+ EHE: std::error::Error + 'static,
{
// eprintln!("before: {:?}", DumpHex(data));
if data.is_empty() { return }
Ok::<_,PE>(())
})() {
Ok(()) => { },
- Err(e) => { err=true; error_handler(e); },
+ Err(e) => { err=true; error_handler(e)?; },
}
}
// eprintln!(" after: {:?}", DumpHex(data));
- if err && !ok { throw!(ErrorOnlyBad) }
+ if err && !ok { throw!(SlipFramesError::ErrorOnlyBad) }
}
#[throws(PacketError)]