Skip to content
Draft
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
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ pub use reply::ReplyPoll;
#[cfg(target_os = "macos")]
pub use reply::ReplyXTimes;
pub use reply::ReplyXattr;
pub use reply::{Reply, ReplyAttr, ReplyData, ReplyEmpty, ReplyEntry, ReplyOpen};
pub use reply::{Reply, ReplyAttr, ReplyData, ReplyEmpty, ReplyEntry, ReplyOpen, ReplySender};
pub use reply::{
ReplyBmap, ReplyCreate, ReplyDirectory, ReplyDirectoryPlus, ReplyIoctl, ReplyLock, ReplyLseek,
ReplyStatfs, ReplyWrite,
};
pub use request::Request;
pub use session::{BackgroundSession, Session, SessionACL, SessionUnmounter};
pub use session::{BackgroundSession, FilesystemSession, Session, SessionACL, SessionUnmounter};
#[cfg(feature = "abi-7-28")]
use std::cmp::max;
use std::cmp::min;
Expand Down
20 changes: 15 additions & 5 deletions src/notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use std::io;
#[allow(unused)]
use std::{convert::TryInto, ffi::OsStr};

use std::sync::Arc;

use crate::{
channel::ChannelSender,
ll::{fuse_abi::fuse_notify_code as notify_code, notify::Notification},

// What we're sending here aren't really replies, but they
Expand All @@ -22,7 +23,7 @@ pub struct PollHandle {
}

impl PollHandle {
pub(crate) fn new(cs: ChannelSender, kh: u64) -> Self {
pub(crate) fn new(cs: Arc<dyn ReplySender>, kh: u64) -> Self {
Self {
handle: kh,
notifier: Notifier::new(cs),
Expand All @@ -48,11 +49,20 @@ impl std::fmt::Debug for PollHandle {
}

/// A handle by which the application can send notifications to the server
#[derive(Debug, Clone)]
pub struct Notifier(ChannelSender);
///
/// The sender is type-erased so that notifications work regardless of the
/// transport carrying FUSE messages, not just `/dev/fuse`.
#[derive(Clone)]
pub struct Notifier(Arc<dyn ReplySender>);

impl std::fmt::Debug for Notifier {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("Notifier").finish()
}
}

impl Notifier {
pub(crate) fn new(cs: ChannelSender) -> Self {
pub(crate) fn new(cs: Arc<dyn ReplySender>) -> Self {
Self(cs)
}

Expand Down
7 changes: 7 additions & 0 deletions src/reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use std::fmt;
use std::io::IoSlice;
#[cfg(feature = "abi-7-40")]
use std::os::fd::BorrowedFd;
use std::sync::Arc;
use std::time::Duration;

#[cfg(target_os = "macos")]
Expand All @@ -46,6 +47,12 @@ impl fmt::Debug for Box<dyn ReplySender> {
}
}

impl ReplySender for Arc<dyn ReplySender> {
fn send(&self, data: &[IoSlice<'_>]) -> std::io::Result<()> {
(**self).send(data)
}
}

/// Generic reply trait
pub trait Reply {
/// Create a new reply for the given request
Expand Down
Loading