Add conversion functions for FileType from fuser

This commit is contained in:
Olivier 'reivilibre' 2022-01-17 23:59:27 +00:00
parent 13c2904f6d
commit 9163bff990
6 changed files with 40 additions and 3 deletions

1
Cargo.lock generated
View File

@ -868,6 +868,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"env_logger",
"fuser",
"log",
"quinn",
"serde",

View File

@ -27,7 +27,7 @@ clap = { version = "3.0.7", features = ["derive"] }
quinn = { version = "0.8.0", features = [] }
# Compression and Encryption
zstd = "0.9.2+zstd.1.5.1"
zstd = "0.9.2"
sodiumoxide = "0.2.7"
rustls = "0.20.2"

View File

@ -23,4 +23,6 @@ toml = "0.5.8"
quinn = { version = "0.8.0", features = [] }
# Compression and Encryption
zstd = "0.9.2+zstd.1.5.1"
zstd = "0.9.2"
fuser = { version = "0.10.0", optional = true }

View File

@ -67,6 +67,9 @@ pub enum FileKind {
Socket,
}
#[cfg(feature = "fuser")]
mod messages_fuser;
/// Copy of fuser's FileAttr. Used to describe a file.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct FileMetadata {

View File

@ -0,0 +1,31 @@
use crate::messages::FileKind;
use fuser::FileType;
use std::fs::FileType;
impl From<FileType> for FileKind {
fn from(filetype: FileType) -> Self {
match filetype {
FileType::NamedPipe => FileKind::NamedPipe,
FileType::CharDevice => FileKind::CharDevice,
FileType::BlockDevice => FileKind::BlockDevice,
FileType::Directory => FileKind::Directory,
FileType::RegularFile => FileKind::RegularFile,
FileType::Symlink => FileKind::Symlink,
FileType::Socket => FileKind::Socket,
}
}
}
impl Into<FileType> for FileKind {
fn into(self) -> FileType {
match self {
FileKind::NamedPipe => FileType::NamedPipe,
FileKind::CharDevice => FileType::CharDevice,
FileKind::BlockDevice => FileType::BlockDevice,
FileKind::Directory => FileType::Directory,
FileKind::RegularFile => FileType::RegularFile,
FileKind::Symlink => FileType::Symlink,
FileKind::Socket => FileType::Socket,
}
}
}

View File

@ -29,7 +29,7 @@ clap = { version = "3.0.7", features = ["derive"] }
quinn = { version = "0.8.0", features = [] }
# Compression and Encryption
zstd = "0.9.2+zstd.1.5.1"
zstd = "0.9.2"
rustls = "0.20.2"
rcgen = { version = "0.8.14", features = ["x509-parser"] }