Skip to main content

async_fuser/ll/reply_async/
lookup.rs

1//! Response data implementation of [`crate::AsyncFilesystem::lookup`] operation to
2//! send to the kernel
3
4#![allow(missing_docs, missing_debug_implementations)]
5
6use std::time::Duration;
7
8use crate::FileAttr;
9use crate::Generation;
10use crate::ll::ResponseStruct;
11use crate::ll::ioslice_concat::IosliceConcat;
12use crate::ll::reply::Attr;
13use crate::ll::reply::Response;
14
15/// Response data from [`crate::AsyncFilesystem::lookup`] operation
16#[derive(Debug)]
17pub struct LookupResponse {
18    ttl: Duration,
19    attr: FileAttr,
20    generation: Generation,
21}
22
23impl LookupResponse {
24    /// `ttl` is the time for which this response may be cached
25    /// `attr` is the attributes of the file
26    /// `generation`
27    pub fn new(ttl: Duration, attr: FileAttr, generation: Generation) -> Self {
28        Self {
29            ttl,
30            attr,
31            generation,
32        }
33    }
34}
35
36impl Response for LookupResponse {
37    fn payload(&self) -> impl IosliceConcat {
38        ResponseStruct::new_entry(
39            self.attr.ino,
40            self.generation,
41            &Attr::from(self.attr),
42            self.ttl,
43            self.ttl,
44        )
45    }
46}