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§
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.
- Acl41
Flags - 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.
- Buffered
File - File convenience wrapper. Reads only the requested range, without prefetch or a retained cache; writes are durable before returning successfully.
- Callback
Stats - Redacted callback counters shared by NFSv4 client engines.
- Export
Entry - 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.
- Lock
Token - A byte-range lock together with everything required to release it safely.
- Mount
Capabilities - Protocol-neutral features exposed by a mounted client.
- Mount
Health - Protocol-neutral mount health. Stateful engines may override the defaults.
- Nfs41
Callback Stats - Redacted NFSv4.1 callback lifecycle counters for reliability diagnostics.
- Nfs41
Channel Limits - 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.
- Open
File - An opened object plus protocol-owned state hidden from callers.
- Pathconf
- Struct describing path configuration for an NFS entry as returned by
Mount::pathconfandMount::pathconf_path. - Pathconf
Support - Availability of the optional NFSv4 attributes represented by
Pathconf. - Readdir
Entry - Struct describing a single NFS entry as returned by
Mount::readdirandMount::readdir_path. - Readdirplus
Entry - Struct describing a single NFS entry as returned by
Mount::readdirplusandMount::readdirplus_path. - Supported
Pathconf - PATHCONF values plus explicit availability for optional NFSv4 attributes.
- Time
- Struct describing an NFS timestamp.
- Write
Outcome - 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).
- Mount
Lifecycle State - High-level lifecycle state of a mount.
- NFSVersion
- Nfs3
Error Code - Nfs3
Mount Error Code - Nfs4
Error Code - Write
Committed - 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.