DataLoader

Struct DataLoader 

Source
pub struct DataLoader<F> { /* private fields */ }
Expand description

Data loader, to load data from files

Implementations§

Source§

impl<F: DataFormatHandler> DataLoader<F>

Source

pub fn new(dir: &Path) -> Result<Self>

Create a new data loader from a directory

Source

pub fn load_file<T: Data>(&mut self, path: impl AsRef<Path>) -> DataReceiver<T>

Load Data from a file

Source

pub fn load_map<M: DataMapper>( &mut self, path: impl AsRef<Path>, mapper: M, ) -> DataReceiver<M::Out>

Load and map data from a file

Source

pub fn load_map_cached<M: DataMapper>( &mut self, path: impl AsRef<Path>, mapper: M, ) -> DataReceiver<M::Out>
where M::Out: Serialize + Data,

Load and map data from a file, but cache the result so the mapper is only invoked if the file has changed

Source

pub fn load<Out: Send + 'static>( &mut self, path: &Path, f: impl FnOnce(&Path) -> Result<Out> + Send + 'static, ) -> DataReceiver<Out>

Loads data from a given path, with a custom Out type

Source

pub fn load_all_files<T: Data, P: AsRef<Path>>( &mut self, paths: impl Iterator<Item = P>, ) -> DataReceiver<Vec<T>>

Load all files from a given iterator of paths

Source

pub fn load_all_mapped<M: DataMapper + Clone, P: AsRef<Path>>( &mut self, paths: impl Iterator<Item = P>, mapper: M, ) -> DataReceiver<Vec<M::Out>>

Load all files from a given iterator of paths, with a custom mapper

Source

pub fn load_all<Out: Send + 'static, P: AsRef<Path>>( &mut self, paths: impl Iterator<Item = P>, f: impl Fn(&Path) -> Result<Out> + Clone + Send + 'static, ) -> DataReceiver<Vec<Out>>

Load all files from a given iterator of paths, with a custom Out type

Source

pub async fn wait_all(self) -> Result<()>

Wait for all pending tasks to finish and update the manifest

Auto Trait Implementations§

§

impl<F> Freeze for DataLoader<F>

§

impl<F> RefUnwindSafe for DataLoader<F>
where F: RefUnwindSafe,

§

impl<F> Send for DataLoader<F>
where F: Send,

§

impl<F> Sync for DataLoader<F>
where F: Sync,

§

impl<F> Unpin for DataLoader<F>
where F: Unpin,

§

impl<F> UnwindSafe for DataLoader<F>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.