diff options
Diffstat (limited to 'src/ops/global.rs')
| -rw-r--r-- | src/ops/global.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/ops/global.rs b/src/ops/global.rs index cd6b260..aa83b1e 100644 --- a/src/ops/global.rs +++ b/src/ops/global.rs @@ -1,3 +1,4 @@ +use super::traits::ReplyOk; use crate::{io::FsInfo, private_trait::Sealed, proto, util::page_size, Done, Operation, Reply}; pub enum Init {} @@ -8,6 +9,10 @@ pub struct InitState { pub(crate) buffer_pages: usize, } +pub trait ReplyFsInfo<'o>: Operation<'o> { + fn info(reply: Reply<'o, Self>, info: &FsInfo) -> Done<'o>; +} + impl Sealed for Init {} impl Sealed for Statfs {} @@ -21,12 +26,12 @@ impl<'o> Operation<'o> for Statfs { type ReplyTail = (); } -impl<'o> Reply<'o, Init> { - pub fn ok(self) -> Done<'o> { +impl<'o> ReplyOk<'o> for Init { + fn ok(reply: Reply<'o, Self>) -> Done<'o> { let InitState { kernel_flags, buffer_pages, - } = self.tail; + } = reply.tail; let flags = { use proto::InitFlags; @@ -63,7 +68,7 @@ impl<'o> Reply<'o, Init> { // See fs/fuse/dev.c in the kernel source tree for details about max_write let max_write = buffer_size - std::mem::size_of::<(proto::InHeader, proto::WriteIn)>(); - self.single(&proto::InitOut { + reply.single(&proto::InitOut { major: proto::MAJOR_VERSION, minor: proto::TARGET_MINOR_VERSION, max_readahead: 0, //TODO @@ -79,9 +84,8 @@ impl<'o> Reply<'o, Init> { } } -impl<'o> Reply<'o, Statfs> { - /// Replies with filesystem statistics. - pub fn info(self, statfs: &FsInfo) -> Done<'o> { - self.single(&proto::StatfsOut::from(*statfs)) +impl<'o> ReplyFsInfo<'o> for Statfs { + fn info(reply: Reply<'o, Self>, fs_info: &FsInfo) -> Done<'o> { + reply.single(&proto::StatfsOut::from(*fs_info)) } } |
