nmd_core/
dumpable.rs

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 std::path::PathBuf;

use getset::{CopyGetters, Getters, Setters};
use thiserror::Error;

use crate::resource::ResourceError;


#[derive(Debug, Error)]
pub enum DumpError {
    #[error(transparent)]
    ResourceError(#[from] ResourceError)
}


#[derive(Debug, Clone, Getters, CopyGetters, Setters)]
pub struct DumpConfiguration {
    
    #[getset(get = "pub", set = "pub")]
    output_path: PathBuf,

    #[getset(get_copy = "pub", set = "pub")]
    force_dump: bool,
}

impl DumpConfiguration {
    pub fn new(output_path: PathBuf, force_dump: bool,) -> Self {
        Self {
            output_path,
            force_dump
        }
    }
}


/// Dump trait. Dump is the operation which permits to save a resource
pub trait Dumpable {

    fn dump(&mut self, configuration: &DumpConfiguration) -> Result<(), DumpError>;
}