diff --git a/src/elements/mod.rs b/src/elements/mod.rs index 3a66a1f..dfe80a3 100644 --- a/src/elements/mod.rs +++ b/src/elements/mod.rs @@ -17,7 +17,7 @@ pub use self::module::Module; pub use self::section::{ Section, FunctionSection, CodeSection, MemorySection, DataSection, ImportSection, ExportSection, GlobalSection, TypeSection, ElementSection, - TableSection, + TableSection, CustomSection, }; pub use self::import_entry::{ImportEntry, ResizableLimits, MemoryType, TableType, GlobalType, External}; pub use self::export_entry::{ExportEntry, Internal}; diff --git a/src/elements/section.rs b/src/elements/section.rs index 7b8e309..8416770 100644 --- a/src/elements/section.rs +++ b/src/elements/section.rs @@ -178,11 +178,35 @@ impl Serialize for Section { } } +/// Custom section pub struct CustomSection { name: String, payload: Vec, } +impl CustomSection { + + /// Name of the custom section + pub fn name(&self) -> &str { + &self.name + } + + /// Payload of the custom secion + pub fn payload(&self) -> &[u8] { + &self.payload + } + + /// Name of the custom section (mutable) + pub fn name_mut(&mut self) -> &mut String { + &mut self.name + } + + /// Payload of the custom section (mutable) + pub fn payload_mut(&mut self) -> &mut Vec { + &mut self.payload + } +} + impl Deserialize for CustomSection { type Error = Error;