/src/wasm-tools/crates/wasm-encoder/src/raw.rs
Line | Count | Source |
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 | 81.6k | fn encode(&self, sink: &mut Vec<u8>) { |
17 | 81.6k | self.data.encode(sink); |
18 | 81.6k | } |
19 | | } |
20 | | |
21 | | impl Section for RawSection<'_> { |
22 | 78.7k | fn id(&self) -> u8 { |
23 | 78.7k | self.id |
24 | 78.7k | } |
25 | | } |
26 | | |
27 | | #[cfg(feature = "component-model")] |
28 | | impl crate::ComponentSection for RawSection<'_> { |
29 | 2.89k | fn id(&self) -> u8 { |
30 | 2.89k | self.id |
31 | 2.89k | } |
32 | | } |