numbat_codec/
nested_ser_output.rs

1use alloc::vec::Vec;
2
3/// Trait that allows appending bytes.
4/// Used especially by the NestedEncode trait to output data.
5///
6/// In principle it can be anything, but in practice
7/// we only keep 1 implementation, which is Vec<u8>.
8/// This is to avoid code duplication by monomorphization.
9pub trait NestedEncodeOutput {
10	/// Write to the output.
11	fn write(&mut self, bytes: &[u8]);
12
13	/// Write a single byte to the output.
14	fn push_byte(&mut self, byte: u8) {
15		self.write(&[byte]);
16	}
17}
18
19impl NestedEncodeOutput for Vec<u8> {
20	fn write(&mut self, bytes: &[u8]) {
21		self.extend_from_slice(bytes)
22	}
23}