summaryrefslogtreecommitdiff
path: root/src/data.rs
blob: 04376bc251fdc3b16cfbbbc85303a8784b0ec8e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::specification::{Create, FileCount};
use std::path::{Path, PathBuf};

/// Test data management for Obnam benchmarks.
///
/// Each backup in a benchmark backs up some test data created for
/// that backup. That data is later cleaned up. Is all handled by this
/// structure.
#[derive(Debug)]
pub struct Data {
    tempdir: PathBuf,
}

/// Possible errors from managing data.
#[derive(Debug, thiserror::Error)]
pub enum DataError {
}

impl Data {
    pub(crate) fn new(tempdir: &Path) -> Result<Self, DataError> {
        Ok(Self {
            tempdir: tempdir.to_path_buf(),
        })
    }

    pub(crate) fn create(&self, create: &Create) -> Result<(), DataError> {
        println!("create {:?} in {}", create, self.tempdir.display());
        Ok(())
    }

    pub(crate) fn rename(&self, count: &FileCount) -> Result<(), DataError> {
        println!("rename {:?}", count);
        Ok(())
    }

    pub(crate) fn delete(&self, count: &FileCount) -> Result<(), DataError> {
        println!("delete {:?}", count);
        Ok(())
    }
}