pub struct AdvReader { /* private fields */ }Expand description
Provides iteration over bytes or utf8 string of words, strings and (line) comments.
use std::path::PathBuf;
use advreader::*;
// construct our iterator from our file input
let reader = AdvReader::default(&PathBuf::from("../testdata/example.txt"));
let mut reader_ok = reader.unwrap();
// walk our item using `while` syntax
for item in reader_ok.into_iter() {
// do something with the item, which is Result<&[u8], _>
}For those who prefer the Iterator API, this structure implements
the IntoIterator trait to provide it. This comes at the cost of
an allocation of a Vec for each line in the Iterator. This is
negligible in many cases, so often it comes down to which syntax
is preferred:
use std::path::PathBuf;
use advreader::*;
// construct our iterator from our file input
let reader = AdvReader::default(&PathBuf::from("../testdata/example.txt"));
let mut reader_ok = reader.unwrap();
// walk our items using `for` syntax
for item in reader_ok.into_iter() {
// do something with the item, which is Result<AdvReturnValue, Error>
}Implementations§
source§impl AdvReader
impl AdvReader
sourcepub fn new(
path: &Path,
buffer_size: Option<usize>,
trim: Option<bool>,
line_end: Option<u8>,
skip_comments: Option<bool>,
encode_comments: Option<bool>,
encode_strings: Option<bool>,
encoder: Option<String>,
allow_invalid_utf8: Option<bool>,
extended_word_separation: Option<bool>,
double_quote_escape: Option<bool>,
convert2numbers: Option<bool>,
keep_base: Option<bool>,
bool_false: Option<Vec<u8>>,
bool_true: Option<Vec<u8>>,
block_reader: Option<Box<dyn Block + Send + Sync>>
) -> Result<Self, Error>
pub fn new( path: &Path, buffer_size: Option<usize>, trim: Option<bool>, line_end: Option<u8>, skip_comments: Option<bool>, encode_comments: Option<bool>, encode_strings: Option<bool>, encoder: Option<String>, allow_invalid_utf8: Option<bool>, extended_word_separation: Option<bool>, double_quote_escape: Option<bool>, convert2numbers: Option<bool>, keep_base: Option<bool>, bool_false: Option<Vec<u8>>, bool_true: Option<Vec<u8>>, block_reader: Option<Box<dyn Block + Send + Sync>> ) -> Result<Self, Error>
Constructs a new AdvReader.
pub fn default(path: &Path) -> Result<Self, Error>
sourcepub fn with_capacity(
path: &Path,
buffer_size: Option<usize>,
trim: Option<bool>,
line_end: Option<u8>,
skip_comments: Option<bool>,
encode_comments: Option<bool>,
encode_strings: Option<bool>,
encoder: Option<String>,
allow_invalid_utf8: Option<bool>,
extended_word_separation: Option<bool>,
double_quote_escape: Option<bool>,
convert2numbers: Option<bool>,
keep_base: Option<bool>,
bool_false: Option<Vec<u8>>,
bool_true: Option<Vec<u8>>,
block_reader: Option<Box<dyn Block + Send + Sync>>
) -> Result<Self, Error>
pub fn with_capacity( path: &Path, buffer_size: Option<usize>, trim: Option<bool>, line_end: Option<u8>, skip_comments: Option<bool>, encode_comments: Option<bool>, encode_strings: Option<bool>, encoder: Option<String>, allow_invalid_utf8: Option<bool>, extended_word_separation: Option<bool>, double_quote_escape: Option<bool>, convert2numbers: Option<bool>, keep_base: Option<bool>, bool_false: Option<Vec<u8>>, bool_true: Option<Vec<u8>>, block_reader: Option<Box<dyn Block + Send + Sync>> ) -> Result<Self, Error>
Constructs a new AdvReader.
pub fn stop(&mut self) -> Result<(usize, ReaderState), Error>
Trait Implementations§
source§impl IntoIterator for AdvReader
impl IntoIterator for AdvReader
IntoIterator conversion for AdvReader to provide Iterator APIs.
Auto Trait Implementations§
impl !RefUnwindSafe for AdvReader
impl Send for AdvReader
impl Sync for AdvReader
impl Unpin for AdvReader
impl !UnwindSafe for AdvReader
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