Struct snowbinary::SnowBinReader
source · pub struct SnowBinReader { /* private fields */ }
Expand description
Allows reading from a SnowBinary
file.
Implementations§
source§impl SnowBinReader
impl SnowBinReader
sourcepub fn new(path: PathBuf) -> Result<Self, SnowBinError>
pub fn new(path: PathBuf) -> Result<Self, SnowBinError>
Creates a new SnowBinReader
. Params are pulled from the file info.
§Example
use std::path::PathBuf;
use snowbinary::{SnowBinInfo, SnowBinReader};
let reader = SnowBinReader::new(PathBuf::from("file.temp")).unwrap();
§Errors
Returns SnowBinError
if the file could not be created or opened, or the file cannot be read from.
sourcepub fn read(&mut self, header: &str) -> Result<Vec<u8>, SnowBinError>
pub fn read(&mut self, header: &str) -> Result<Vec<u8>, SnowBinError>
Reads data from the file using the header.
§Example
use std::path::PathBuf;
use snowbinary::{SnowBinError, SnowBinInfo, SnowBinReader};
let mut reader = SnowBinReader::new(PathBuf::from("file.temp"));
match &mut reader {
Ok(reader) => {
let data = reader.read("Header"); // May return error
}
Err(_) => {}
}
§Errors
Returns SnowBinError
if the file cannot be read from or the end of the file was reached.
§Panics
Panics could happen if data size is over i64::MAX
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SnowBinReader
impl RefUnwindSafe for SnowBinReader
impl Send for SnowBinReader
impl Sync for SnowBinReader
impl Unpin for SnowBinReader
impl UnwindSafe for SnowBinReader
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