Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace async-trait crate with AFIT feature #76

Merged
merged 7 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ build: &BUILD
- rustup component add clippy
- cargo check --all-targets --features=tokio-runtime,file-lock,unprivileged
- cargo check --all-targets --features=async-std-runtime,file-lock,unprivileged
- cargo doc --no-deps --features=doc
# - RUSTDOCFLAGS="--cfg docsrs" cargo doc --features=file-lock,unprivileged,tokio-runtime # disable until doc_cfg and doc_auto_cfg are stable
- cargo doc --features=file-lock,unprivileged,tokio-runtime
- cargo clippy --all-targets --features=tokio-runtime,file-lock,unprivileged
- cargo clippy --all-targets --features=async-std-runtime,file-lock,unprivileged
before_cache_script: rm -rf $HOME/.cargo/registry/index
Expand Down
28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ categories = ["api-bindings", "filesystem"]
license = "MIT"
repository = "https://github.com/Sherlock-Holo/fuse3"
description = "FUSE user-space library async version implementation."
rust-version = "1.63"
rust-version = "1.75"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -21,22 +21,21 @@ tokio-runtime = ["tokio"]
async-std-runtime = ["async-std", "async-io"]
file-lock = []
unprivileged = ["nix/socket", "which"]
doc = ["file-lock", "unprivileged", "tokio-runtime"]

[dependencies]
futures-util = { version = "0.3", features = ["sink"] }
futures-channel = { version = "0.3", features = ["sink"] }
async-trait = "0.1.2"
cstr = "0.2"
libc = "0.2.147"
bincode = "1.3.1"
serde = { version = "1.0.103", features = ["derive"] }
nix = { version = "0.27", default-features = false, features = ["fs", "mount"] }
which = { version = "4", optional = true }
async-io = { version = "1.4", optional = true }
bincode = "1.3.3"
bytes = "1"
slab = "0.4.2"
tracing = "0.1.21"
cstr = "0.2"
futures-channel = { version = "0.3", features = ["sink"] }
futures-util = { version = "0.3", features = ["sink"] }
libc = "0.2.153"
nix = { version = "0.27", default-features = false, features = ["fs", "mount"] }
serde = { version = "1.0.196", features = ["derive"] }
slab = "0.4.9"
tracing = "0.1.40"
trait-make = "0.1"
which = { version = "6", optional = true }

[target.'cfg(target_os = "linux")'.dependencies]
nix = { version = "0.27", default-features = false, features = ["user"] }
Expand All @@ -52,7 +51,8 @@ features = ["fs", "rt", "sync", "net", "macros"]
optional = true

[package.metadata.docs.rs]
features = [ "doc" ]
rustdoc-args = ["--cfg", "docsrs"]
features = ["file-lock", "unprivileged", "tokio-runtime"]
targets = [
"i686-unknown-freebsd",
"i686-unknown-linux-gnu",
Expand Down
5 changes: 2 additions & 3 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ path = "src/path_memfs/main.rs"

[dependencies]
fuse3 = { path = "../", features = ["tokio-runtime", "unprivileged"] }
async-trait = "0.1.2"
libc = "0.2.147"
libc = "0.2.153"
tokio = { version = "1", features = ["macros", "rt", "time"] }
futures-util = "0.3"
mio = { version = "0.8", features = ["os-poll"] }
tempfile = "3"
bytes = "1"
tracing = "0.1.21"
tracing = "0.1.40"
tracing-subscriber = "0.3"
2 changes: 0 additions & 2 deletions examples/src/helloworld/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::iter::Skip;
use std::time::{Duration, SystemTime};
use std::vec::IntoIter;

use async_trait::async_trait;
use bytes::Bytes;
use fuse3::raw::prelude::*;
use fuse3::{MountOptions, Result};
Expand Down Expand Up @@ -33,7 +32,6 @@ const STATFS: ReplyStatFs = ReplyStatFs {

struct HelloWorld;

#[async_trait]
impl Filesystem for HelloWorld {
type DirEntryStream = Iter<Skip<IntoIter<Result<DirectoryEntry>>>>;
type DirEntryPlusStream = Iter<Skip<IntoIter<Result<DirectoryEntryPlus>>>>;
Expand Down
2 changes: 0 additions & 2 deletions examples/src/memfs/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::sync::Arc;
use std::time::{Duration, SystemTime};
use std::vec::IntoIter;

use async_trait::async_trait;
use bytes::{Buf, BytesMut};
use fuse3::raw::prelude::*;
use fuse3::{Errno, Inode, MountOptions, Result};
Expand Down Expand Up @@ -188,7 +187,6 @@ impl Default for Fs {
}
}

#[async_trait]
impl Filesystem for Fs {
type DirEntryStream = Empty<Result<DirectoryEntry>>;
type DirEntryPlusStream = Iter<IntoIter<Result<DirectoryEntryPlus>>>;
Expand Down
2 changes: 0 additions & 2 deletions examples/src/path_memfs/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::io::{Cursor, Read, Write};
use std::time::{Duration, SystemTime};
use std::vec::IntoIter;

use async_trait::async_trait;
use bytes::{Buf, BufMut, BytesMut};
use fuse3::path::prelude::*;
use fuse3::{Errno, MountOptions, Result};
Expand Down Expand Up @@ -138,7 +137,6 @@ impl Default for Fs {
}
}

#[async_trait]
impl PathFilesystem for Fs {
type DirEntryStream = Empty<Result<DirectoryEntry>>;
type DirEntryPlusStream = Iter<IntoIter<Result<DirectoryEntryPlus>>>;
Expand Down
2 changes: 0 additions & 2 deletions examples/src/poll/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::sync::Arc;
use std::time::{Duration, SystemTime};
use std::vec::IntoIter;

use async_trait::async_trait;
use bytes::Bytes;
use fuse3::raw::prelude::*;
use fuse3::{MountOptions, Result};
Expand All @@ -32,7 +31,6 @@ struct Poll {
ready: Arc<AtomicBool>,
}

#[async_trait]
impl Filesystem for Poll {
type DirEntryStream = Iter<Skip<IntoIter<Result<DirectoryEntry>>>>;
type DirEntryPlusStream = Iter<Skip<IntoIter<Result<DirectoryEntryPlus>>>>;
Expand Down
2 changes: 1 addition & 1 deletion src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn mode_from_kind_and_perm(kind: FileType, perm: u16) -> u32 {
}

/// returns the permission for a given file kind and mode
#[allow(clippy::unnecessary_cast)] // Not unnecessary on all platforms.
#[allow(clippy::unnecessary_cast)] // Not unnecessary on all platforms.
pub fn perm_from_mode_and_kind(kind: FileType, mode: mode_t) -> u16 {
(mode ^ mode_t::from(kind)) as u16
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
//!
//! You must enable `async-std-runtime` or `tokio-runtime` feature.

#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

use std::{
convert::TryInto,
time::{Duration, SystemTime, UNIX_EPOCH},
};

/// re-export [`async_trait`][async_trait::async_trait].
pub use async_trait::async_trait;
pub use errno::Errno;
pub use helper::{mode_from_kind_and_perm, perm_from_mode_and_kind};
pub use mount_options::MountOptions;
Expand Down
2 changes: 1 addition & 1 deletion src/mount_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ impl MountOptions {
opts.push("allow_other".to_string());
}

if matches!(self.read_only, true) {
if self.read_only {
opts.push("ro".to_string());
}

Expand Down
2 changes: 0 additions & 2 deletions src/path/inode_path_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::vec::IntoIter;

#[cfg(all(not(feature = "tokio-runtime"), feature = "async-std-runtime"))]
use async_std::sync::RwLock;
use async_trait::async_trait;
use bytes::Bytes;
use futures_util::stream::{self, Iter, Stream, StreamExt};
use slab::Slab;
Expand Down Expand Up @@ -144,7 +143,6 @@ impl<FS> Debug for InodePathBridge<FS> {
}
}

#[async_trait]
impl<FS> Filesystem for InodePathBridge<FS>
where
FS: PathFilesystem + Send + Sync,
Expand Down
3 changes: 1 addition & 2 deletions src/path/path_filesystem.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::ffi::OsStr;

use async_trait::async_trait;
use bytes::Bytes;
use futures_util::stream::Stream;

Expand All @@ -16,7 +15,7 @@ use crate::notify::Notify;
use crate::{Result, SetAttr};

#[allow(unused_variables)]
#[async_trait]
#[trait_make::make(Send)]
/// Path based filesystem trait.
///
/// # Notes:
Expand Down
3 changes: 1 addition & 2 deletions src/raw/filesystem.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::ffi::OsStr;

use async_trait::async_trait;
use bytes::Bytes;
use futures_util::stream::Stream;

Expand All @@ -10,7 +9,7 @@ use crate::raw::request::Request;
use crate::{Inode, Result, SetAttr};

#[allow(unused_variables)]
#[async_trait]
#[trait_make::make(Send)]
/// Inode based filesystem trait.
///
/// # Notes:
Expand Down
2 changes: 1 addition & 1 deletion src/raw/request.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::raw::abi::fuse_in_header;

#[derive(Debug, Default, Copy, Clone, Eq, PartialEq)]
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)]
/// Request data
pub struct Request {
/// the unique identifier of this request.
Expand Down
7 changes: 3 additions & 4 deletions src/raw/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,9 @@ impl<FS: Filesystem + Send + Sync + 'static> Session<FS> {
task::spawn(async move { Self::reply_fuse(fuse_write_connection, receiver).await })
.fuse();
#[cfg(all(not(feature = "async-std-runtime"), feature = "tokio-runtime"))]
let reply_task =
task::spawn(Self::reply_fuse(fuse_write_connection, receiver))
.fuse()
.map(Result::unwrap);
let reply_task = task::spawn(Self::reply_fuse(fuse_write_connection, receiver))
.fuse()
.map(Result::unwrap);

pin_mut!(reply_task);

Expand Down