pub struct FileLoader<'a, T> { /* private fields */ }Expand description
Iterator pipeline for loading UTF-8 documents. Reads happen synchronously during iteration; per-item I/O and decoding errors are yielded unless filtered.
Implementations§
Source§impl<'a, T: Readable + 'a> FileLoader<'a, T>
impl<'a, T: Readable + 'a> FileLoader<'a, T>
Sourcepub fn read(self) -> FileLoader<'a, Result<String, FileLoaderError>>
pub fn read(self) -> FileLoader<'a, Result<String, FileLoaderError>>
Decodes each input as UTF-8 during iteration, yielding I/O or decoding errors.
let content = FileLoader::with_glob("files/*.txt")?.read();
for result in content {
match result {
Ok(content) => println!("{content}"),
Err(e) => eprintln!("Error reading file: {e}"),
}
}Sourcepub fn read_with_path(
self,
) -> FileLoader<'a, Result<(PathBuf, String), FileLoaderError>>
pub fn read_with_path( self, ) -> FileLoader<'a, Result<(PathBuf, String), FileLoaderError>>
Decodes each input as UTF-8 and pairs it with its source path, yielding
I/O or decoding errors. In-memory inputs use the path <memory>.
let content = FileLoader::with_glob("files/*.txt")?.read_with_path();
for result in content {
match result {
Ok((path, content)) => println!("{path:?} {content}"),
Err(e) => eprintln!("Error reading file: {e}"),
}
}Source§impl<'a, T: 'a> FileLoader<'a, Result<T, FileLoaderError>>
impl<'a, T: 'a> FileLoader<'a, Result<T, FileLoaderError>>
Sourcepub fn ignore_errors(self) -> FileLoader<'a, T>
pub fn ignore_errors(self) -> FileLoader<'a, T>
Discards error items and yields unwrapped successful values.
Source§impl<'a> FileLoader<'a, Result<PathBuf, FileLoaderError>>
impl<'a> FileLoader<'a, Result<PathBuf, FileLoaderError>>
Sourcepub fn with_glob(
pattern: &str,
) -> Result<FileLoader<'_, Result<PathBuf, FileLoaderError>>, FileLoaderError>
pub fn with_glob( pattern: &str, ) -> Result<FileLoader<'_, Result<PathBuf, FileLoaderError>>, FileLoaderError>
Creates a loader over glob matches. Invalid patterns fail immediately; traversal errors are yielded during iteration.
Sourcepub fn with_dir(
directory: &str,
) -> Result<FileLoader<'_, Result<PathBuf, FileLoaderError>>, FileLoaderError>
pub fn with_dir( directory: &str, ) -> Result<FileLoader<'_, Result<PathBuf, FileLoaderError>>, FileLoaderError>
Creates a new loader on all files within a directory (ignores subdirectories).
Source§impl<'a> FileLoader<'a, Vec<u8>>
impl<'a> FileLoader<'a, Vec<u8>>
Sourcepub fn from_bytes(bytes: Vec<u8>) -> FileLoader<'a, Vec<u8>>
pub fn from_bytes(bytes: Vec<u8>) -> FileLoader<'a, Vec<u8>>
Ingest a document as a byte array.
Sourcepub fn from_bytes_multi(bytes_vec: Vec<Vec<u8>>) -> FileLoader<'a, Vec<u8>>
pub fn from_bytes_multi(bytes_vec: Vec<Vec<u8>>) -> FileLoader<'a, Vec<u8>>
Ingest multiple byte arrays.
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> !RefUnwindSafe for FileLoader<'a, T>
impl<'a, T> !Send for FileLoader<'a, T>
impl<'a, T> !Sync for FileLoader<'a, T>
impl<'a, T> !UnwindSafe for FileLoader<'a, T>
impl<'a, T> Freeze for FileLoader<'a, T>
impl<'a, T> Unpin for FileLoader<'a, T>
impl<'a, T> UnsafeUnpin for FileLoader<'a, T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more