multiversx_sc_codec/single/
nested_en_output.rs1use alloc::vec::Vec;
2
3use crate::{EncodeError, EncodeErrorHandler, TryStaticCast};
4
5pub trait NestedEncodeOutput {
12 fn write(&mut self, bytes: &[u8]);
14
15 fn push_byte(&mut self, byte: u8) {
17 self.write(&[byte]);
18 }
19
20 #[inline]
21 fn supports_specialized_type<T: TryStaticCast>() -> bool {
22 false
23 }
24
25 #[inline]
26 fn push_specialized<T, C, H>(
27 &mut self,
28 _context: C,
29 _value: &T,
30 h: H,
31 ) -> Result<(), H::HandledErr>
32 where
33 T: TryStaticCast,
34 C: TryStaticCast,
35 H: EncodeErrorHandler,
36 {
37 Err(h.handle_error(EncodeError::UNSUPPORTED_OPERATION))
38 }
39}
40
41impl NestedEncodeOutput for Vec<u8> {
42 fn write(&mut self, bytes: &[u8]) {
43 self.extend_from_slice(bytes)
44 }
45}