pub struct FileReader { /* private fields */ }Expand description
A .verit file read into memory, owning its bytes.
FileView borrows the image it reads, which means it cannot be stored in
the same struct as the buffer it points into — so every caller ends up
writing the same { bytes: Vec<u8> } wrapper. This is that wrapper, once.
let file = FileReader::open("events.verit")?;
let view = file.view()?;
for i in 0..view.len() {
println!("{}", view.dump_json(i)?);
}For a large file, mmap it with your platform’s facility and hand the
mapped &[u8] to FileView::open directly — the reader never copies a
record either way, and a map avoids reading bytes nothing touches.
Implementations§
Source§impl FileReader
impl FileReader
Sourcepub fn open<P>(path: P) -> Result<FileReader, Error>
pub fn open<P>(path: P) -> Result<FileReader, Error>
Read and validate a file. Structural errors surface here rather than at first access.
Sourcepub fn from_bytes(bytes: Vec<u8>) -> Result<FileReader, Error>
pub fn from_bytes(bytes: Vec<u8>) -> Result<FileReader, Error>
Take ownership of an already-read image, validating it.
Trait Implementations§
Source§impl Clone for FileReader
impl Clone for FileReader
Source§fn clone(&self) -> FileReader
fn clone(&self) -> FileReader
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FileReader
impl RefUnwindSafe for FileReader
impl Send for FileReader
impl Sync for FileReader
impl Unpin for FileReader
impl UnsafeUnpin for FileReader
impl UnwindSafe for FileReader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more