Struct calypso_filety::ccff::ContainerFile
source · Expand description
A CCFF container file.
This will contain all the sections of data (somewhat similar in theory to ELF sections) as well as some basic metadata about the file: its ABI version and file type, both of which are user-defined.
It also stores a list of Section
s, which can be accessed and modified
via methods on this structure such as get_section
and add_section
. The order of these sections is
stored, however this is not guaranteed or required and may be changed in
the future.
Fields§
§abiver: u16
§filety: u8
§sections: IndexMap<String, Section>
Implementations§
source§impl ContainerFile
impl ContainerFile
sourcepub fn new(abiver: u16, filety: u8) -> Self
pub fn new(abiver: u16, filety: u8) -> Self
Create a new container file. The ABI version (abiver
) and file type
(filety
) may be any arbitrary user-defined value.
sourcepub fn set_abiver(&mut self, abiver: u16)
pub fn set_abiver(&mut self, abiver: u16)
Set the ABI version of the container file. This may be any arbitrary user-defined value.
sourcepub fn get_abiver(&self) -> u16
pub fn get_abiver(&self) -> u16
Get the ABI version of the container file.
sourcepub fn set_filety(&mut self, filety: u8)
pub fn set_filety(&mut self, filety: u8)
Set the file type of the container file. This may be any arbitrary user-defined value.
sourcepub fn get_filety(&self) -> u8
pub fn get_filety(&self) -> u8
Get the file type of the container file.
sourcepub fn add_section(&mut self, name: String, section: Section) -> Option<Section>
pub fn add_section(&mut self, name: String, section: Section) -> Option<Section>
Add a section to the container file. If there was already a section with this name present, it will be replaced and returned.
Panics
This function will panic if the name of the section was longer than 255
characters, if the name of the section contained non-printable ASCII
characters (less than 0x21
or greater than 0x7E
), or if there were
already 255 sections in the container file.
sourcepub fn remove_section(&mut self, name: &str) -> Option<Section>
pub fn remove_section(&mut self, name: &str) -> Option<Section>
Remove a section from the container file. The removed section, if any, will be returned.
sourcepub fn get_section(&self, name: &str) -> Option<&Section>
pub fn get_section(&self, name: &str) -> Option<&Section>
Get a reference to a section in the container file.
sourcepub fn get_section_mut(&mut self, name: &str) -> Option<&mut Section>
pub fn get_section_mut(&mut self, name: &str) -> Option<&mut Section>
Get a mutable reference to a section in the container file.
sourcepub fn sections(&self) -> impl Iterator<Item = (&String, &Section)>
pub fn sections(&self) -> impl Iterator<Item = (&String, &Section)>
Iterate over the sections in the container file.
sourcepub fn sections_mut(&mut self) -> impl Iterator<Item = (&String, &mut Section)>
pub fn sections_mut(&mut self) -> impl Iterator<Item = (&String, &mut Section)>
Iterate mutably over the sections in the container file.
sourcepub fn decode(buf: &[u8]) -> Result<Self, Err<Error<Vec<u8>>>>
pub fn decode(buf: &[u8]) -> Result<Self, Err<Error<Vec<u8>>>>
Decode this container file from the buffer provided.
Errors
This function will return an error if the input fails to parse.
sourcepub fn encode_to(self, buf: &mut Vec<u8>)
pub fn encode_to(self, buf: &mut Vec<u8>)
Encode this container file to the buffer provided. To allocate a
sufficiently sized buffer, use Vec::with_capacity
using the size
given by ContainerFile::size
.
Panics
This function will panic if a section was too large (larger than
u32::MAX
in bytes) or if there was too much data in the container
file (due to architectural limitations, they are capped at around 4GiB)
Trait Implementations§
source§impl Clone for ContainerFile
impl Clone for ContainerFile
source§fn clone(&self) -> ContainerFile
fn clone(&self) -> ContainerFile
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ContainerFile
impl Debug for ContainerFile
source§impl IntoIterator for ContainerFile
impl IntoIterator for ContainerFile
source§impl PartialEq<ContainerFile> for ContainerFile
impl PartialEq<ContainerFile> for ContainerFile
source§fn eq(&self, other: &ContainerFile) -> bool
fn eq(&self, other: &ContainerFile) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for ContainerFile
impl StructuralEq for ContainerFile
impl StructuralPartialEq for ContainerFile
Auto Trait Implementations§
impl RefUnwindSafe for ContainerFile
impl Send for ContainerFile
impl Sync for ContainerFile
impl Unpin for ContainerFile
impl UnwindSafe for ContainerFile
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.