Skip to main content

NfsReadFileSystem

Trait NfsReadFileSystem 

Source
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§

Source

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§

Source

fn root_dir(&self) -> Self::Handle

Returns the ID the of the root directory “/”

Source

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.

Source

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.

Source

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.

Source

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,…

Reads a symlink

Provided Methods§

Source

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.

Source

fn readdir( &self, dirid: &Self::Handle, cookie: u64, ) -> impl Future<Output = Result<impl ReadDirIterator, nfsstat3>> + Send

Simple version of readdir. Only need to return filename and id

By default it uses readdirplus method to create an iterator

Source

fn fsinfo( &self, root_fileid: &Self::Handle, ) -> impl Future<Output = Result<fsinfo3, nfsstat3>> + Send

Get static file system Information

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§