pub struct FileEditFile<'a> { /* private fields */ }
Expand description
File file editor.
Implementations§
Source§impl<'a> FileEditFile<'a>
impl<'a> FileEditFile<'a>
Sourcepub fn descriptor(&self) -> &Descriptor
pub fn descriptor(&self) -> &Descriptor
Gets the file descriptor as-is.
Sourcepub fn set_content(
&mut self,
content_type: u32,
content_size: u32,
) -> &mut FileEditFile<'a>
pub fn set_content( &mut self, content_type: u32, content_size: u32, ) -> &mut FileEditFile<'a>
Sets the content type and size for this file descriptor.
Note that a content type of 0
gets overwritten by a type of 1
.
Sourcepub fn set_section(&mut self, section: &Section) -> &mut FileEditFile<'a>
pub fn set_section(&mut self, section: &Section) -> &mut FileEditFile<'a>
Assigns an existing section object to this file descriptor.
This can be used to make different descriptors point to the same data.
Sourcepub fn allocate_data(&mut self) -> &mut FileEditFile<'a>
pub fn allocate_data(&mut self) -> &mut FileEditFile<'a>
Allocates and assigns space for the data.
The size allocated is defined by a previous call to set_content
’s content_size
argument.
The space allocated is logically uninitialized and must be initialized with write_data
or zero_data
.
Sourcepub fn write_data(
&mut self,
data: &[u8],
key: &Key,
) -> Result<&mut FileEditFile<'a>>
pub fn write_data( &mut self, data: &[u8], key: &Key, ) -> Result<&mut FileEditFile<'a>>
Copies and encrypts the data with the given key into the address specified by this file descriptor.
Sourcepub fn zero_data(&mut self, key: &Key) -> Result<&mut FileEditFile<'a>>
pub fn zero_data(&mut self, key: &Key) -> Result<&mut FileEditFile<'a>>
Initialize the data with zeroes.
Sourcepub fn reencrypt_data(&mut self, old_key: &Key, key: &Key) -> Result<()>
pub fn reencrypt_data(&mut self, old_key: &Key, key: &Key) -> Result<()>
Reencrypts the data.
The file must be initialized (either through init_data
or zero_data
) before it can be updated.
§Consistency guarantees
The file contents are updated inplace. In the case of a failure (forced crash or power loss) the consistency is not guaranteed.
If consistency is important, consider removing & creating the file again instead.