pub struct VersionedFile { /* private fields */ }
Expand description
VersionedFile defines the main type for the crate, and implements an API for safely manipulating versioned files. The API is based on the async_std::File interface, but with some adjustments that are designed to make it both safer and more ergonomic. For example, len() is exposed directly rather than having to first fetch the file metadata. Another example, all calls to write will automatically flush() the file.
If a function is not fully documented, it is safe to assume that the function follows the same convensions/rules as its equivalent function for async_std::File.
Implementations§
Source§impl VersionedFile
impl VersionedFile
Sourcepub async fn len(&mut self) -> Result<u64, Error>
pub async fn len(&mut self) -> Result<u64, Error>
len will return the size of the file, not including the versioned header.
Sourcepub async fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
pub async fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
read_exact will read from the data portion of a VersionedFile. If there is an error, the contents of buf are unspecified, and the read offset will not be updated.
Sourcepub async fn seek(&mut self, pos: SeekFrom) -> Result<u64, Error>
pub async fn seek(&mut self, pos: SeekFrom) -> Result<u64, Error>
seek will seek to the provided offset within the file, ignoring the header.
Sourcepub async fn set_len(&mut self, new_len: u64) -> Result<(), Error>
pub async fn set_len(&mut self, new_len: u64) -> Result<(), Error>
set_len will truncate the file so that it has the provided length, excluding the header. This operation can be used to make the file larger as well. This operation will put the cursor at the end of the file after the length has been set.