pub struct Loader<'a> { /* private fields */ }Expand description
Perform a streaming load of only relevant database tables.
Example
This example loads just the version_downloads.csv table, in which each row is the download count for a single version of a single crate on a single day. We do not store the rows individually in memory but instead stream from the csv to accumulate just a total count per day across all crates, which requires far less memory.
use chrono::NaiveDate;
use std::collections::BTreeMap as Map;
fn main() -> db_dump::Result<()> {
    let mut downloads = Map::<NaiveDate, u64>::new();
    db_dump::Loader::new()
        .version_downloads(|row| {
            *downloads.entry(row.date).or_default() += row.downloads;
        })
        .load("./db-dump.tar.gz")?;
    for (date, count) in downloads {
        println!("{},{}", date, count);
    }
    Ok(())
}Implementations
sourceimpl<'a> Loader<'a>
 
impl<'a> Loader<'a>
pub fn new() -> Self
pub fn badges(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn categories(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn crate_owners(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn crates(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn crates_categories(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn crates_keywords(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn dependencies(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn keywords(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn metadata(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn reserved_crate_names(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn teams(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn users(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn version_downloads(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn versions(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self
pub fn load(&mut self, path: impl AsRef<Path>) -> Result<()>
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Loader<'a>
impl<'a> !Send for Loader<'a>
impl<'a> !Sync for Loader<'a>
impl<'a> Unpin for Loader<'a>
impl<'a> !UnwindSafe for Loader<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
    T: ?Sized, 
 
impl<T> BorrowMut<T> for T where
    T: ?Sized, 
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more