nmd_core/
dumpable.rs

1use std::path::PathBuf;
2
3use getset::{CopyGetters, Getters, Setters};
4use thiserror::Error;
5
6use crate::resource::ResourceError;
7
8
9#[derive(Debug, Error)]
10pub enum DumpError {
11    #[error(transparent)]
12    ResourceError(#[from] ResourceError)
13}
14
15
16#[derive(Debug, Clone, Getters, CopyGetters, Setters)]
17pub struct DumpConfiguration {
18    
19    #[getset(get = "pub", set = "pub")]
20    output_path: PathBuf,
21
22    #[getset(get_copy = "pub", set = "pub")]
23    force_dump: bool,
24}
25
26impl DumpConfiguration {
27    pub fn new(output_path: PathBuf, force_dump: bool,) -> Self {
28        Self {
29            output_path,
30            force_dump
31        }
32    }
33}
34
35
36/// Dump trait. Dump is the operation which permits to save a resource
37pub trait Dumpable {
38
39    fn dump(&mut self, configuration: &DumpConfiguration) -> Result<(), DumpError>;
40}