blown_fuse/
lib.rs

1//! An asynchronous and high-level implementation of the Filesystem in Userspace protocol.
2//!
3//! `blown-fuse`
4
5#![forbid(unsafe_code)]
6#![feature(try_trait_v2)]
7
8#[cfg(not(target_os = "linux"))]
9compile_error!("Unsupported OS");
10
11use std::marker::PhantomData;
12
13pub use self::error::{FuseError, FuseResult};
14
15#[doc(no_inline)]
16pub use nix::{self, errno::Errno};
17
18pub mod error;
19pub mod io;
20pub mod mount;
21pub mod ops;
22pub mod session;
23
24mod proto;
25mod util;
26
27pub trait Operation<'o>: sealed::Sealed + Sized {
28    type RequestBody: crate::proto::Structured<'o>;
29    type ReplyState;
30}
31
32pub type Op<'o, O = ops::Any> = (Request<'o, O>, Reply<'o, O>);
33
34pub struct Request<'o, O: Operation<'o>> {
35    header: proto::InHeader,
36    body: O::RequestBody,
37}
38
39#[must_use]
40pub struct Reply<'o, O: Operation<'o>> {
41    session: &'o session::Session,
42    unique: u64,
43    state: O::ReplyState,
44}
45
46#[must_use]
47pub struct Done<'o>(PhantomData<&'o mut &'o ()>);
48
49impl Done<'_> {
50    fn new() -> Self {
51        Done(PhantomData)
52    }
53
54    fn consume(self) {
55        drop(self);
56    }
57}
58
59mod sealed {
60    pub trait Sealed {}
61}