encdec_base/decode/mod.rs
1//! [`Decode`] trait implementation
2
3use core::fmt::Debug;
4
5use crate::Error;
6
7mod owned;
8pub use owned::DecodeOwned;
9
10mod ext;
11pub use ext::{DecodeExt, DecodeIter};
12
13mod tagged;
14pub use tagged::DecodedTagged;
15
16mod prefixed;
17pub use prefixed::DecodePrefixed;
18
19/// Decode trait implemented for binary decodable objects
20pub trait Decode<'a>: Sized {
21 /// Output type (allows attaching lifetime bounds where required)
22 type Output: Debug;
23
24 /// Error type returned on parse error
25 type Error: From<Error> + Debug;
26
27 /// Decode consumes a slice and returns an object and decoded length.
28 fn decode(buff: &'a [u8]) -> Result<(Self::Output, usize), Self::Error>;
29}