pub fn export(
        &self,
    ) -> Vec<(
        CollectionType,
        CollectionName,
        impl Iterator<Item = Vec<Vec<u8>>> + '_,
    )> {
        let trees = self.trees.lock();

        let mut ret = vec![];

        for kv_res in self.collection_name_mapping.iter() {
            let (collection_name, collection_id_buf) = kv_res.unwrap();
            let collection_id = CollectionId(u64::from_le_bytes(
                collection_id_buf.as_ref().try_into().unwrap(),
            ));
            let tree = trees.get(&collection_id).unwrap().clone();

            ret.push((
                b"tree".to_vec(),
                collection_name.to_vec(),
                tree.iter().map(|kv_opt| {
                    let kv = kv_opt.unwrap();
                    vec![kv.0.to_vec(), kv.1.to_vec()]
                }),
            ));
        }

        ret
    }
A database export method for all collections in the `Db`,
for use in sled version upgrades. Can be used in combination
with the `import` method below on a database running a later
version.

# Panics

Panics if any IO problems occur while trying
to perform the export.

# Examples

If you want to migrate from one version of sled
to another, you need to pull in both versions
by using version renaming:

`Cargo.toml`:

```toml
[dependencies]
sled = "0.32"
old_sled = { version = "0.31", package = "sled" }
```

and in your code, remember that old versions of
sled might have a different way to open them
than the current `sled::open` method:

```
# use sled as old_sled;
# fn main() -> Result<(), Box<dyn std::error::Error>> {
let old = old_sled::open("my_old_db_export")?;

// may be a different version of sled,
// the export type is version agnostic.
let new = sled::open("my_new_db_export")?;

let export = old.export();
new.import(export);

assert_eq!(old.checksum()?, new.checksum()?);
# drop(old);
# drop(new);
# let _ = std::fs::remove_dir_all("my_old_db_export");
# let _ = std::fs::remove_dir_all("my_new_db_export");
# Ok(()) }
```
src/db.rs