multiversx_sc_codec/single/
nested_de_input.rs1pub use crate::codec_err::DecodeError;
2use crate::{DecodeErrorHandler, TryStaticCast};
3
4pub trait NestedDecodeInput {
6 fn remaining_len(&self) -> usize;
8
9 fn is_depleted(&self) -> bool {
11 self.remaining_len() == 0
12 }
13
14 fn peek_into<H>(&mut self, into: &mut [u8], h: H) -> Result<(), H::HandledErr>
18 where
19 H: DecodeErrorHandler;
20
21 fn read_into<H>(&mut self, into: &mut [u8], h: H) -> Result<(), H::HandledErr>
25 where
26 H: DecodeErrorHandler;
27
28 #[inline]
29 fn supports_specialized_type<T: TryStaticCast>() -> bool {
30 false
31 }
32
33 fn read_specialized<T, C, H>(&mut self, _context: C, h: H) -> Result<T, H::HandledErr>
34 where
35 T: TryStaticCast,
36 C: TryStaticCast,
37 H: DecodeErrorHandler,
38 {
39 Err(h.handle_error(DecodeError::UNSUPPORTED_OPERATION))
40 }
41
42 fn read_byte<H>(&mut self, h: H) -> Result<u8, H::HandledErr>
44 where
45 H: DecodeErrorHandler,
46 {
47 let mut buf = [0u8];
48 self.read_into(&mut buf[..], h)?;
49 Ok(buf[0])
50 }
51}