sys_mount/
fstype.rs

1// Copyright 2018-2022 System76 <info@system76.com>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4use crate::supported::SupportedFilesystems;
5
6/// Defines how the file system type should be derived for a mount -- auto or manual
7#[derive(Clone, Copy, Debug)]
8pub enum FilesystemType<'a> {
9    /// The automatic variant will iterate through a list of pre-generated supported
10    /// file systems, and attempt to mount each one before giving up.
11    Auto(&'a SupportedFilesystems),
12    /// The caller can avoid costly trial-and-error iteration with this variant.
13    Manual(&'a str),
14    /// A specific set of file systems to attempt to mount with.
15    Set(&'a [&'a str]),
16}
17
18impl<'a> From<&'a SupportedFilesystems> for FilesystemType<'a> {
19    fn from(s: &'a SupportedFilesystems) -> Self {
20        FilesystemType::Auto(s)
21    }
22}
23
24impl<'a> From<&'a str> for FilesystemType<'a> {
25    fn from(s: &'a str) -> Self {
26        FilesystemType::Manual(s)
27    }
28}
29
30impl<'a> From<&'a [&'a str]> for FilesystemType<'a> {
31    fn from(s: &'a [&'a str]) -> Self {
32        FilesystemType::Set(s)
33    }
34}