# Snapshots

> UStore for Rust

`use ustore::SaveConfig;`

`use ustore::Snapshot;`

`use ustore::db::Save;`

## SaveConfig

Where a save writes and how it reports; see [`On::save`](#save).

```rust
pub struct SaveConfig<'config, Path>
```

- `path` `Path`: The directory of the new database.
- `progress` `Option<&'config mut ProgressCallback<'config>>`: Reports the bytes saved and stops wherever it says to, removing what the save wrote.

Implements: `From<Path>`

## Snapshot

A point-in-time view of the whole database, which pins the versions its reads need until it is dropped.

```rust
pub struct Snapshot<'db>
```

Every view at a snapshot borrows it, so the snapshot outlives them, and the snapshot borrows its
database, which it is freed before. Dropping it waits for every deferred call naming it to finish.

Implements: `Debug`, `Drop`, `Send`

## view

The view every call at this snapshot addresses, which no write may go through.

```rust
pub fn view(&self) -> On<'_, Snapshot<'db>>
```

## on

The view of this snapshot with every call through it running on `executor`.

```rust
pub fn on<'with>(&'with self, executor: &'with Executor) -> On<'with, Snapshot<'db>>
```

## deferred

The view of this snapshot with every verb deferred on `executor`.

```rust
pub fn deferred<'with>(&'with self, executor: &'with Executor) -> DeferredOn<'with, Snapshot<'db>>
```

## read_stamp

The stamp this snapshot reads at, at or above the commit stamp of every commit it sees.

```rust
pub fn read_stamp(&self) -> ReadStamp
```

## save

Writes this snapshot out as a new database of the same engine; see [`On::save`](#save).

```rust
pub fn save<'config, Path: AsRef<str>>(
    &self,
    config: impl Into<SaveConfig<'config, Path>>,
) -> Result<()>
```

## Save

A save of a snapshot as a database of its own; see [`On::save`](#save).

```rust
pub struct Save<'progress, Path>
```

Implements: `Debug`

