Skip to content

Commit 24585f0

Browse files
committed
macos_session: add with_writer for macOS
macos_session originally lacked the `with_writer` API. This commit ports the implementation from `linux_session` to provide a consistent interface across platforms.
1 parent 2f6ff6f commit 24585f0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/transport/fusedev/macos_session.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,19 @@ impl FuseSession {
189189
}
190190
}
191191

192+
/// Create a new fuse message writer and pass it to the given closure.
193+
pub fn with_writer<F>(&mut self, f: F)
194+
where
195+
F: FnOnce(FuseDevWriter),
196+
{
197+
if let Some(file) = &self.file {
198+
let fd = file.as_raw_fd();
199+
let mut buf = vec![0x0u8; self.bufsize];
200+
let writer = FuseDevWriter::new(fd, &mut buf).unwrap();
201+
f(writer);
202+
}
203+
}
204+
192205
/// Wake channel loop
193206
/// After macfuse unmount, read will throw ENODEV
194207
/// So wakers is no need for macfuse to interrupt channel

0 commit comments

Comments
 (0)