diff --git a/src/rcore/inlining.rs b/src/rcore/inlining.rs index 7a97dac..1ccce60 100644 --- a/src/rcore/inlining.rs +++ b/src/rcore/inlining.rs @@ -1,6 +1,9 @@ use super::*; +/// [`Deserializer`] with a cleaner interface for parsing multiple objects +/// from one stream ("inlining"). pub trait Inlining: Sized { + /// Try to read `n` bytes. Consumes the deserializer on failure. fn iread_n( self, n: usize, @@ -8,8 +11,10 @@ pub trait Inlining: Sized { err: impl FnOnce(&[u8]) -> E, ) -> Result<(A, Self), E>; + /// Read all bytes, consuming the deserializer. fn iread_all(self, ok: impl FnOnce(&[u8]) -> A) -> A; + /// Re-export of [`Deserializer::tell`]. fn itell(&self) -> usize; } @@ -20,7 +25,7 @@ pub trait InliningExt: Inlining { ) -> Result<([u8; N], Self), E> { self.iread_n( N, - |slice| slice.try_into().expect("iread_n wrong length."), + |slice| slice.try_into().expect("`iread_n` wrong length."), err, ) }