Struct db_dump::Loader[][src]

pub struct Loader<'a> { /* fields omitted */ }

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("./dbdump.tar.gz")?;

    for (date, count) in downloads {
        println!("{},{}", date, count);
    }

    Ok(())
}

Implementations

impl<'a> Loader<'a>[src]

pub fn new() -> Self[src]

pub fn badges(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn categories(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn crate_owners(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn crates(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn crates_categories(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn crates_keywords(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn dependencies(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn keywords(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn metadata(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn reserved_crate_names(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn teams(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn users(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn version_authors(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn version_downloads(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn versions(&mut self, f: impl FnMut(Row) + 'a) -> &mut Self[src]

pub fn load(&mut self, path: impl AsRef<Path>) -> Result<()>[src]

Trait Implementations

impl<'a> Default for Loader<'a>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.