testnumbat_codec/
nested_ser_output.rs1use alloc::vec::Vec;
2
3use crate::{EncodeError, 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 push_specialized<T, C, F>(
22 &mut self,
23 _context: C,
24 _value: &T,
25 else_serialization: F,
26 ) -> Result<(), EncodeError>
27 where
28 T: TryStaticCast,
29 C: TryStaticCast,
30 F: FnOnce(&mut Self) -> Result<(), EncodeError>,
31 {
32 else_serialization(self)
33 }
34}
35
36impl NestedEncodeOutput for Vec<u8> {
37 fn write(&mut self, bytes: &[u8]) {
38 self.extend_from_slice(bytes)
39 }
40}