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