/// Encoding for the `component-name` custom section which assigns /// human-readable names to items within a component. #[derive(Clone, Debug, Default)] pubstruct ComponentNameSection {
bytes: Vec<u8>,
}
enum Subsection {
Component,
Decls,
}
impl ComponentNameSection { /// Creates a new blank `name` custom section. pubfn new() -> Self { Self::default()
}
/// Appends a component name subsection to this section. /// /// This will indicate that the name of the entire component should be the /// `name` specified. Note that this should be encoded first before other /// subsections. pubfn component(&mutself, name: &str) { let len = encoding_size(u32::try_from(name.len()).unwrap()); self.subsection_header(Subsection::Component, len + name.len());
name.encode(&mutself.bytes);
}
/// Appends a decls name subsection to name core functions within the /// component. pubfn core_funcs(&mutself, names: &NameMap) { self.core_decls(ExportKind::Func as u8, names)
}
/// Appends a decls name subsection to name core tables within the /// component. pubfn core_tables(&mutself, names: &NameMap) { self.core_decls(ExportKind::Table as u8, names)
}
/// Appends a decls name subsection to name core memories within the /// component. pubfn core_memories(&mutself, names: &NameMap) { self.core_decls(ExportKind::Memory as u8, names)
}
/// Appends a decls name subsection to name core globals within the /// component. pubfn core_globals(&mutself, names: &NameMap) { self.core_decls(ExportKind::Global as u8, names)
}
/// Appends a decls name subsection to name core types within the /// component. pubfn core_types(&mutself, names: &NameMap) { self.core_decls(CORE_TYPE_SORT, names)
}
/// Appends a decls name subsection to name core modules within the /// component. pubfn core_modules(&mutself, names: &NameMap) { self.core_decls(CORE_MODULE_SORT, names)
}
/// Appends a decls name subsection to name core instances within the /// component. pubfn core_instances(&mutself, names: &NameMap) { self.core_decls(CORE_INSTANCE_SORT, names)
}
/// Appends a decls name subsection to name component functions within the /// component. pubfn funcs(&mutself, names: &NameMap) { self.component_decls(FUNCTION_SORT, names)
}
/// Appends a decls name subsection to name component values within the /// component. pubfn values(&mutself, names: &NameMap) { self.component_decls(VALUE_SORT, names)
}
/// Appends a decls name subsection to name component type within the /// component. pubfn types(&mutself, names: &NameMap) { self.component_decls(TYPE_SORT, names)
}
/// Appends a decls name subsection to name components within the /// component. pubfn components(&mutself, names: &NameMap) { self.component_decls(COMPONENT_SORT, names)
}
/// Appends a decls name subsection to name component instances within the /// component. pubfn instances(&mutself, names: &NameMap) { self.component_decls(INSTANCE_SORT, names)
}
/// Appends a raw subsection with the given id and data. pubfn raw(&mutself, id: u8, data: &[u8]) { self.bytes.push(id);
data.encode(&mutself.bytes);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.