pub trait NfsReadFileSystem: Send + Sync {
type Handle: FileHandle;
// Required methods
fn root_dir(&self) -> Self::Handle;
fn lookup(
&self,
dirid: &Self::Handle,
filename: &filename3<'_>,
) -> impl Future<Output = Result<Self::Handle, nfsstat3>> + Send;
fn getattr(
&self,
id: &Self::Handle,
) -> impl Future<Output = Result<fattr3, nfsstat3>> + Send;
fn read(
&self,
id: &Self::Handle,
offset: u64,
count: u32,
) -> impl Future<Output = Result<(Vec<u8>, bool), nfsstat3>> + Send;
fn readdirplus(
&self,
dirid: &Self::Handle,
cookie: u64,
) -> impl Future<Output = Result<impl ReadDirPlusIterator<Self::Handle>, nfsstat3>> + Send;
fn readlink(
&self,
id: &Self::Handle,
) -> impl Future<Output = Result<nfspath3<'_>, nfsstat3>> + Send;
// Provided methods
fn lookup_by_path(
&self,
path: &str,
) -> impl Future<Output = Result<Self::Handle, nfsstat3>> + Send { ... }
fn readdir(
&self,
dirid: &Self::Handle,
cookie: u64,
) -> impl Future<Output = Result<impl ReadDirIterator, nfsstat3>> + Send { ... }
fn fsinfo(
&self,
root_fileid: &Self::Handle,
) -> impl Future<Output = Result<fsinfo3, nfsstat3>> + Send { ... }
}Expand description
Read-only file system interface
This should be enough to implement a read-only NFS server.
If you want to implement a read-write server, you should implement
the NfsFileSystem trait too.
Required Associated Types§
Sourcetype Handle: FileHandle
type Handle: FileHandle
Type that can be used to indentify a file or folder in the file system.
For more information, see FileHandle.
Required Methods§
Sourcefn lookup(
&self,
dirid: &Self::Handle,
filename: &filename3<'_>,
) -> impl Future<Output = Result<Self::Handle, nfsstat3>> + Send
fn lookup( &self, dirid: &Self::Handle, filename: &filename3<'_>, ) -> impl Future<Output = Result<Self::Handle, nfsstat3>> + Send
Look up the id of a path in a directory
i.e. given a directory dir/ containing a file a.txt
this may call lookup(id_of("dir/"), "a.txt")
and this should return the id of the file dir/a.txt
This method should be fast as it is used very frequently.
Sourcefn getattr(
&self,
id: &Self::Handle,
) -> impl Future<Output = Result<fattr3, nfsstat3>> + Send
fn getattr( &self, id: &Self::Handle, ) -> impl Future<Output = Result<fattr3, nfsstat3>> + Send
Returns the attributes of an id. This method should be fast as it is used very frequently.
Sourcefn read(
&self,
id: &Self::Handle,
offset: u64,
count: u32,
) -> impl Future<Output = Result<(Vec<u8>, bool), nfsstat3>> + Send
fn read( &self, id: &Self::Handle, offset: u64, count: u32, ) -> impl Future<Output = Result<(Vec<u8>, bool), nfsstat3>> + Send
Reads the contents of a file returning (bytes, EOF) Note that offset/count may go past the end of the file and that in that case, all bytes till the end of file are returned. EOF must be flagged if the end of the file is reached by the read.
Sourcefn readdirplus(
&self,
dirid: &Self::Handle,
cookie: u64,
) -> impl Future<Output = Result<impl ReadDirPlusIterator<Self::Handle>, nfsstat3>> + Send
fn readdirplus( &self, dirid: &Self::Handle, cookie: u64, ) -> impl Future<Output = Result<impl ReadDirPlusIterator<Self::Handle>, nfsstat3>> + Send
Returns the contents of a directory with pagination.
Directory listing should be deterministic.
Up to max_entries may be returned, and start_after is used
to determine where to start returning entries from.
For instance if the directory has entry with ids [1,6,2,11,8,9]
and start_after=6, readdir should returning 2,11,8,…
Provided Methods§
Sourcefn lookup_by_path(
&self,
path: &str,
) -> impl Future<Output = Result<Self::Handle, nfsstat3>> + Send
fn lookup_by_path( &self, path: &str, ) -> impl Future<Output = Result<Self::Handle, nfsstat3>> + Send
This method is used when the client tries to mount a subdirectory.
The default implementation walks the directory structure with lookup.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
Source§impl NfsReadFileSystem for MemFs
Available on crate feature memfs only.
impl NfsReadFileSystem for MemFs
memfs only.