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
41
42
43
44
45
// Copyright (C) 2023 Ant Group. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

use self::super::CachePolicy;
use std::fmt;
use std::time::Duration;

#[derive(Default, Clone, Debug)]
pub struct Config {
    pub mountpoint: String,
    pub work: String,
    pub do_import: bool,
    // Filesystem options.
    pub writeback: bool,
    pub no_open: bool,
    pub no_opendir: bool,
    pub killpriv_v2: bool,
    pub no_readdir: bool,
    pub perfile_dax: bool,
    pub cache_policy: CachePolicy,
    pub attr_timeout: Duration,
    pub entry_timeout: Duration,
}

impl Clone for CachePolicy {
    fn clone(&self) -> Self {
        match *self {
            CachePolicy::Never => CachePolicy::Never,
            CachePolicy::Always => CachePolicy::Always,
            CachePolicy::Auto => CachePolicy::Auto,
        }
    }
}

impl fmt::Debug for CachePolicy {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let policy = match *self {
            CachePolicy::Never => "Never",
            CachePolicy::Always => "Always",
            CachePolicy::Auto => "Auto",
        };

        write!(f, "CachePolicy: {}", policy)
    }
}