Struct calypso_filety::ccff::ContainerFile
source · [−]pub struct ContainerFile { /* private fields */ }
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.
Implementations
sourceimpl 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: Symbol, section: Section) -> Option<Section>
pub fn add_section(&mut self, name: Symbol, 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: Symbol) -> Option<Section>
pub fn remove_section(&mut self, name: Symbol) -> Option<Section>
Remove a section from the container file. The removed section, if any, will be returned.
sourcepub fn get_section(&self, name: Symbol) -> Option<&Section>
pub fn get_section(&self, name: Symbol) -> Option<&Section>
Get a reference to a section in the container file.
sourcepub fn get_section_mut(&mut self, name: Symbol) -> Option<&mut Section>
pub fn get_section_mut(&mut self, name: Symbol) -> Option<&mut Section>
Get a mutable reference to a section in the container file.
sourcepub fn sections(&self) -> impl Iterator<Item = (&Symbol, &Section)>
pub fn sections(&self) -> impl Iterator<Item = (&Symbol, &Section)>
Iterate over the sections in the container file.
sourcepub fn sections_mut(&mut self) -> impl Iterator<Item = (&Symbol, &mut Section)>
pub fn sections_mut(&mut self) -> impl Iterator<Item = (&Symbol, &mut Section)>
Iterate mutably over the sections in the container file.
sourcepub fn decode(buf: &[u8]) -> CalResult<Self>
pub fn decode(buf: &[u8]) -> CalResult<Self>
Decode this container file from the buffer provided.
Errors
This function will return an error (specifically, a nom::Err
boxed
in an eyre::Report
) 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
sourceimpl Clone for ContainerFile
impl Clone for ContainerFile
sourcefn clone(&self) -> ContainerFile
fn clone(&self) -> ContainerFile
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ContainerFile
impl Debug for ContainerFile
sourceimpl IntoIterator for ContainerFile
impl IntoIterator for ContainerFile
sourceimpl PartialEq<ContainerFile> for ContainerFile
impl PartialEq<ContainerFile> for ContainerFile
sourcefn eq(&self, other: &ContainerFile) -> bool
fn eq(&self, other: &ContainerFile) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ContainerFile) -> bool
fn ne(&self, other: &ContainerFile) -> bool
This method tests for !=
.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more