diff options
| author | Alejandro Soto <alejandro@34project.org> | 2022-01-04 06:49:48 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2022-01-04 06:49:52 -0600 |
| commit | 70baa472b2bee69f205cc1aada304d597b858005 (patch) | |
| tree | 7a0b1a0381b68fe0e091b87d00634ff13568bf6d /src/lib.rs | |
| parent | 1955ec118a32d3fa174496abe5442c82c609273a (diff) | |
Move crate::fuse::* to the top-level
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 60 |
1 files changed, 51 insertions, 9 deletions
@@ -8,16 +8,51 @@ #[cfg(not(target_os = "linux"))] compile_error!("Unsupported OS"); -use std::time::{SystemTime, UNIX_EPOCH}; +use std::{ + marker::PhantomData, + time::{SystemTime, UNIX_EPOCH}, +}; pub use nix; -pub use crate::fuse::*; pub use nix::errno::Errno; pub use util::{FuseError, FuseResult}; +pub mod io; +pub mod mount; +pub mod ops; +pub mod session; + mod proto; mod util; -mod fuse; + +pub trait Operation<'o>: private_trait::Sealed + Sized { + type RequestBody: crate::proto::Structured<'o>; + type ReplyTail; +} + +pub type Op<'o, O = ops::Any> = (Request<'o, O>, Reply<'o, O>); + +pub struct Request<'o, O: Operation<'o>> { + header: proto::InHeader, + body: O::RequestBody, +} + +#[must_use] +pub struct Reply<'o, O: Operation<'o>> { + session: &'o session::Session, + unique: u64, + tail: O::ReplyTail, +} + +/// Inode number. +/// +/// This is a public newtype. Users are expected to inspect the underlying `u64` and construct +/// arbitrary `Ino` objects. +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] +pub struct Ino(pub u64); + +#[must_use] +pub struct Done<'o>(PhantomData<&'o mut &'o ()>); #[derive(Copy, Clone, Eq, PartialEq)] pub struct Ttl { @@ -31,12 +66,15 @@ pub struct Timestamp { nanoseconds: u32, } -/// Inode number. -/// -/// This is a public newtype. Users are expected to inspect the underlying `u64` and construct -/// arbitrary `Ino` objects. -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] -pub struct Ino(pub u64); +impl Done<'_> { + fn new() -> Self { + Done(PhantomData) + } + + fn consume(self) { + drop(self); + } +} impl Ino { /// The invalid inode number, mostly useful for internal aspects of the FUSE protocol. @@ -122,3 +160,7 @@ impl From<SystemTime> for Timestamp { } } } + +mod private_trait { + pub trait Sealed {} +} |
