pub struct WebC<'data> {
pub version: u64,
pub checksum: Option<Checksum>,
pub signature: Option<Signature>,
pub manifest: Manifest,
pub atoms: Volume<'data>,
pub volumes: IndexMap<String, Volume<'data>>,
}
Expand description
Container file, lazily parsed from a set of &'data [u8]
bytes
Fields§
§version: u64
Version of the file format
checksum: Option<Checksum>
Parsed checksum (optional in case of no encoded checksum)
signature: Option<Signature>
Parsed signature (optional if file was not signed)
manifest: Manifest
Manifest of the file, see section §2.3.1
of the spec
atoms: Volume<'data>
Executable files, indexed into one volume (a.wasm
=> a
, b.wasm
=> b@0.2.1
)
volumes: IndexMap<String, Volume<'data>>
Filesystem volumes: default volume name is atom
(containing files of the current package)
and user/package@version
for external dependencies. Every dependency can be sandboxed to only
access its own filesystem volume, not external ones.
Implementations§
source§impl<'a> WebC<'a>
impl<'a> WebC<'a>
pub fn get_main_args_for_command( &self, command: &str ) -> Result<Vec<String>, String>
pub fn get_atom_name_for_command( &self, api: &str, command: &str ) -> Result<String, String>
sourcepub fn check_magic_header(data: &[u8]) -> Result<(), Error>
pub fn check_magic_header(data: &[u8]) -> Result<(), Error>
Checks whether the file starts with the header MAGIC
sourcepub fn get_volumes_for_package(&self, package: &str) -> Vec<String>
pub fn get_volumes_for_package(&self, package: &str) -> Vec<String>
Determines the available volumes for a given package
pub fn list_directories(&self, volume: &str) -> Vec<String>
sourcepub fn read_dir(
&self,
package: &str,
path: &str
) -> Result<Vec<FsEntry<'a>>, Error>
pub fn read_dir( &self, package: &str, path: &str ) -> Result<Vec<FsEntry<'a>>, Error>
Returns the directory entries or an error if the directory does not exist
sourcepub fn get_file_entry(
&self,
package: &str,
path: &str
) -> Option<(String, OwnedFsEntryFile)>
pub fn get_file_entry( &self, package: &str, path: &str ) -> Option<(String, OwnedFsEntryFile)>
Looks for the first volume containing “entry”, scoped to the given package
sourcepub fn get_check_version(data: &[u8]) -> Result<u64, Error>
pub fn get_check_version(data: &[u8]) -> Result<u64, Error>
Checks whether the version of the file is supported by the parsing implementation
sourcepub fn get_checksum_bytes(data: &[u8]) -> Result<&[u8], Error>
pub fn get_checksum_bytes(data: &[u8]) -> Result<&[u8], Error>
Returns the bytes of the checksum
sourcepub fn get_manifest_offset_size(data: &[u8]) -> ReadResult<(usize, usize)>
pub fn get_manifest_offset_size(data: &[u8]) -> ReadResult<(usize, usize)>
Returns the offset of the manifest start
pub fn get_manifest(data: &[u8]) -> Result<Manifest, Error>
sourcepub fn get_atoms_volume_offset_size(data: &[u8]) -> ReadResult<(usize, usize)>
pub fn get_atoms_volume_offset_size(data: &[u8]) -> ReadResult<(usize, usize)>
Returns the offset of the .atoms
section of the file
sourcepub fn get_atoms_volume(data: &'a [u8]) -> Result<Volume<'a>, Error>
pub fn get_atoms_volume(data: &'a [u8]) -> Result<Volume<'a>, Error>
Parses the .atoms
section of the file
sourcepub fn get_volume_data_offsets(
data: &[u8]
) -> Result<BTreeMap<String, (usize, usize)>, Error>
pub fn get_volume_data_offsets( data: &[u8] ) -> Result<BTreeMap<String, (usize, usize)>, Error>
Returns the offsets of the “volume”
pub fn parse_volumes_from_fileblock( data: &'a [u8] ) -> ReadResult<IndexMap<String, Volume<'a>>>
sourcepub fn parse_volumes(data: &'a [u8]) -> ReadResult<IndexMap<String, Volume<'a>>>
pub fn parse_volumes(data: &'a [u8]) -> ReadResult<IndexMap<String, Volume<'a>>>
Parses the .volumes
section(s) of the file
sourcepub fn compute_checksum(data: &[u8]) -> ReadResult<Option<Checksum>>
pub fn compute_checksum(data: &[u8]) -> ReadResult<Option<Checksum>>
Computes the checksum of the file without cloning it
pub const fn get_signature_offset_start() -> usize
sourcepub fn get_signature_offset_size(data: &[u8]) -> ReadResult<(usize, usize)>
pub fn get_signature_offset_size(data: &[u8]) -> ReadResult<(usize, usize)>
Returns the offset of the signature
sourcepub fn get_signature_bytes(data: &[u8]) -> ReadResult<&[u8]>
pub fn get_signature_bytes(data: &[u8]) -> ReadResult<&[u8]>
Read the signature bytes
sourcepub fn get_signature(data: &[u8]) -> ReadResult<Option<Signature>>
pub fn get_signature(data: &[u8]) -> ReadResult<Option<Signature>>
Returns the (unverified) signature from the file
sourcepub fn get_metadata(&self) -> &Manifest
pub fn get_metadata(&self) -> &Manifest
Returns a reference to the manifest
sourcepub fn get_package_name(&self) -> String
pub fn get_package_name(&self) -> String
Returns the current package name with
sourcepub fn get_atom(&self, package: &str, atom: &str) -> Result<&[u8], Error>
pub fn get_atom(&self, package: &str, atom: &str) -> Result<&[u8], Error>
Returns an atom by name for a given package
sourcepub fn get_volume(&self, package: &str, volume: &str) -> Option<&Volume<'a>>
pub fn get_volume(&self, package: &str, volume: &str) -> Option<&Volume<'a>>
Returns a reference to the filesystem volume of the package
sourcepub fn get_file(&self, package: &str, file_path: &str) -> Result<&[u8], Error>
pub fn get_file(&self, package: &str, file_path: &str) -> Result<&[u8], Error>
Returns a file for a given package - if you want to use a non-default
volume, prefix the file_path
with volume://
, for example, metadata://README.md
sourcepub fn list_volumes(&self, package: &str) -> Vec<String>
pub fn list_volumes(&self, package: &str) -> Vec<String>
Returns a list of volumes for this package
sourcepub fn list_packages(&self) -> Vec<PackageInfo>
pub fn list_packages(&self) -> Vec<PackageInfo>
Returns a list of bundled “package@version” strings contained in this package
sourcepub fn list_atoms(&self) -> Vec<String>
pub fn list_atoms(&self) -> Vec<String>
Returns the atoms in the root package
sourcepub fn get_all_atoms(&self) -> IndexMap<String, &'a [u8]>
pub fn get_all_atoms(&self) -> IndexMap<String, &'a [u8]>
Returns a list of all atoms with bytes
sourcepub fn list_atoms_for_package(&self, package_orig: &str) -> Vec<String>
pub fn list_atoms_for_package(&self, package_orig: &str) -> Vec<String>
List the atoms for a given package
sourcepub fn list_commands(&self) -> Vec<&str>
pub fn list_commands(&self) -> Vec<&str>
List the available commands for the root package
sourcepub fn parse(data: &'a [u8], options: &ParseOptions) -> ReadResult<Self>
pub fn parse(data: &'a [u8], options: &ParseOptions) -> ReadResult<Self>
Parses the entire file, depending on the ParseOptions
pub fn get_volumes_as_fileblock(&self) -> Vec<u8> ⓘ
sourcepub fn into_bytes(&self, sign_bytes: GenerateChecksum) -> ReadResult<Vec<u8>>
pub fn into_bytes(&self, sign_bytes: GenerateChecksum) -> ReadResult<Vec<u8>>
Serialize the .webc file into bytes