Skip to main content

Crate nfs_rs

Crate nfs_rs 

Source
Expand description

An asynchronous, pure Rust client library for NFSv3 and NFSv4.1.

Start with parse_url_and_mount to connect to an NFS export. The returned Mount trait object provides file, directory, metadata, link, and filesystem operations shared across the supported protocol versions.

use bytes::Bytes;
use nfs_rs::{OPEN_READ, Result, parse_url_and_mount};

let mount = parse_url_and_mount(
    "nfs://127.0.0.1/some/export?version=4.1&noresvport=true",
)
.await?;

let created = mount.create_path("hello.txt", Some(0o644)).await?;
nfs_rs::write_all(&*mount, created.fh.clone(), 0, Bytes::from_static(b"hello NFS"))
    .await?;
mount.close(created.fh).await?;

let opened = mount.open_path("hello.txt", OPEN_READ).await?;
let contents = mount.read(opened.fh.clone(), 0, 9).await?;
mount.close(opened.fh).await?;
assert_eq!(&contents[..], b"hello NFS");

mount.umount().await?;

By default the client binds a privileged source port. Add noresvport=true when the server export accepts non-privileged source ports.

Re-exports§

pub use error::NfsError;
pub use error::OperationClass;
pub use error::OperationOutcome;
pub use error::OperationOutcomeError;
pub use error::RecoveryAction;
pub use error::RequestContext;
pub use error::RequestId;
pub use error::RequestTransmission;
pub use error::Result;

Modules§

error

Structs§

AceFlags
NFSv4 ACE flags bitfield (RFC 7530 §6.2.1.4).
AceMask
NFSv4 ACE access mask bitfield (RFC 7530 §6.2.1.3).
Acl
NFSv4 ACL: ordered list of access control entries.
Acl41Flags
NFSv4.1 ACL-wide flags carried by FATTR4_DACL and FATTR4_SACL.
AclSupport
Bitmask of ACE types supported by the server (FATTR4_ACLSUPPORT, attr #13).
Attr
Struct describing attributes for an NFS entry.
BufferedFile
File convenience wrapper. Reads only the requested range, without prefetch or a retained cache; writes are durable before returning successfully.
CallbackStats
Redacted callback counters shared by NFSv4 client engines.
ExportEntry
A single entry returned by Mount::exports: an exported path and the list of allowed client groups (empty = unrestricted / world-accessible).
FSInfo
Struct describing non-volatile file system state information.
FSStat
Struct describing volatile file system state information.
LockToken
A byte-range lock together with everything required to release it safely.
MountCapabilities
Protocol-neutral features exposed by a mounted client.
MountHealth
Protocol-neutral mount health. Stateful engines may override the defaults.
Nfs41CallbackStats
Redacted NFSv4.1 callback lifecycle counters for reliability diagnostics.
Nfs41ChannelLimits
Negotiated and currently effective NFSv4.1 fore-channel bounds.
NfsAce
A single NFSv4 Access Control Entry (RFC 7530 §6.2.1).
NfsAcl41
NFSv4.1 DACL/SACL value (nfsacl41): ACL-wide flags plus ordered ACEs.
ObjRes
Struct describing an NFS entry response as returned by various procedures.
OpenFile
An opened object plus protocol-owned state hidden from callers.
Pathconf
Struct describing path configuration for an NFS entry as returned by Mount::pathconf and Mount::pathconf_path.
PathconfSupport
Availability of the optional NFSv4 attributes represented by Pathconf.
ReaddirEntry
Struct describing a single NFS entry as returned by Mount::readdir and Mount::readdir_path.
ReaddirplusEntry
Struct describing a single NFS entry as returned by Mount::readdirplus and Mount::readdirplus_path.
SupportedPathconf
PATHCONF values plus explicit availability for optional NFSv4 attributes.
Time
Struct describing an NFS timestamp.
WriteOutcome
Protocol write acknowledgement used by higher-level durability adapters. Result of one WRITE as reported by the server.

Enums§

AceType
NFSv4 ACE type (RFC 7530 §6.2.1.1).
MountLifecycleState
High-level lifecycle state of a mount.
NFSVersion
Nfs3ErrorCode
Nfs3MountErrorCode
Nfs4ErrorCode
WriteCommitted
Server-reported WRITE commitment (RFC 1813 §3.3.7, RFC 7530 §16.38, RFC 5661 §18.32). This describes the response, not the requested stability.

Constants§

OPEN_BOTH
OPEN_READ
Access modes for Mount::open.
OPEN_WRITE

Traits§

Mount
Trait which defines the procedures that can be performed on an NFS mount.

Functions§

list_exports
Queries the MOUNT service on the given host and returns all exported file systems.
parse_url_and_mount
Parses the specified URL and attempts to mount the relevant NFS export
write_all
Write all bytes and finish their data/metadata commit before returning. Uses at most 8 concurrent disjoint chunks, completing short writes before a single batch commit. Retains the payload for bounded verifier recovery. Calls on the same mount and file handle are serialized, including calls through separate adapters. Callers must coordinate overlapping writes made through other mounts. Cancellation may leave a partially executed write; adapters should settle this future even if their caller is cancelled.

Type Aliases§

ReaddirStream
ReaddirplusStream