| 1 | use crate::{Encode, Section}; |
| 2 | use alloc::vec::Vec; |
| 3 | |
| 4 | /// A section made up of uninterpreted, raw bytes. |
| 5 | /// |
| 6 | /// Allows you to splat any data into a module or component. |
| 7 | #[derive (Clone, Copy, Debug)] |
| 8 | pub struct RawSection<'a> { |
| 9 | /// The id for this section. |
| 10 | pub id: u8, |
| 11 | /// The raw data for this section. |
| 12 | pub data: &'a [u8], |
| 13 | } |
| 14 | |
| 15 | impl Encode for RawSection<'_> { |
| 16 | fn encode(&self, sink: &mut Vec<u8>) { |
| 17 | self.data.encode(sink); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | impl Section for RawSection<'_> { |
| 22 | fn id(&self) -> u8 { |
| 23 | self.id |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | #[cfg (feature = "component-model" )] |
| 28 | impl crate::ComponentSection for RawSection<'_> { |
| 29 | fn id(&self) -> u8 { |
| 30 | self.id |
| 31 | } |
| 32 | } |
| 33 | |