1use std::str::FromStr;
2
3#[derive(Debug, Clone, Copy)]
4#[non_exhaustive]
5pub enum Strategy {
6 Iokit,
8 Diskutil,
11}
12
13#[derive(Debug, Clone, Copy)]
14pub struct ReadOptions {
15 pub(crate) remote_stats: bool,
16 pub(crate) strategy: Option<Strategy>,
17}
18impl Default for ReadOptions {
19 fn default() -> Self {
20 Self {
21 remote_stats: true,
22 strategy: None,
23 }
24 }
25}
26impl ReadOptions {
27 pub fn remote_stats(
28 mut self,
29 v: bool,
30 ) -> Self {
31 self.remote_stats = v;
32 self
33 }
34 pub fn strategy(
35 mut self,
36 v: Strategy,
37 ) -> Self {
38 self.strategy = Some(v);
39 self
40 }
41}
42
43#[derive(Debug, Clone, Copy, PartialEq, Eq)]
44pub struct ParseStrategyError;
45impl FromStr for Strategy {
46 type Err = ParseStrategyError;
47 fn from_str(s: &str) -> Result<Self, Self::Err> {
48 match s {
49 "iokit" => Ok(Self::Iokit),
50 "diskutil" => Ok(Self::Diskutil),
51 _ => Err(ParseStrategyError),
52 }
53 }
54}