pub struct Client { /* private fields */ }Expand description
One ZeroFS session, one identity. Share via Arc; every method takes
&self and is safe to call concurrently. The underlying connection
reconnects transparently, blocking calls through outages; bound waits with
your async runtime’s timeout facilities (every future is cancel-safe).
Paths are bytes, as on POSIX and the 9P wire: every path parameter is
impl AsRef<Path>, so &str, PathBuf, and OsStr::from_bytes(..) for
non-UTF-8 names all work.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn connect(target: &str) -> Result<Arc<Client>, ZeroFsError>
pub async fn connect(target: &str) -> Result<Arc<Client>, ZeroFsError>
Connect with defaults. Targets: "unix:/sock", "tcp://host:port",
"host:port", "host" (port 5564), or a bare filesystem path (unix
socket).
Sourcepub async fn connect_with(
target: &str,
opts: ConnectOptions,
) -> Result<Arc<Client>, ZeroFsError>
pub async fn connect_with( target: &str, opts: ConnectOptions, ) -> Result<Arc<Client>, ZeroFsError>
Connect with explicit identity, timeout, and tuning.
Sourcepub fn capabilities(&self) -> Capabilities
pub fn capabilities(&self) -> Capabilities
Snapshot of currently negotiated session properties (may change across transparent reconnects).
Sourcepub async fn close(&self)
pub async fn close(&self)
Mark the client closed (later calls return Closed), then hand the root
fid to the janitor for a background clunk + recycle. Always succeeds,
idempotent, and never blocks (no await), so a cancelled close still
reclaims the root fid. Outstanding File/Dir handles keep working until
individually closed.
Sourcepub async fn read(&self, path: impl AsRef<Path>) -> Result<Bytes, ZeroFsError>
pub async fn read(&self, path: impl AsRef<Path>) -> Result<Bytes, ZeroFsError>
Read the entire file into memory. Returns Bytes: a whole file that
fits in one round trip comes back with no copy.
Sourcepub async fn read_range(
&self,
path: impl AsRef<Path>,
offset: u64,
len: u32,
) -> Result<Bytes, ZeroFsError>
pub async fn read_range( &self, path: impl AsRef<Path>, offset: u64, len: u32, ) -> Result<Bytes, ZeroFsError>
Read up to len bytes at offset; a shorter result means EOF.
Sourcepub async fn write(
&self,
path: impl AsRef<Path>,
data: &[u8],
) -> Result<(), ZeroFsError>
pub async fn write( &self, path: impl AsRef<Path>, data: &[u8], ) -> Result<(), ZeroFsError>
Create-or-truncate path (mode 0o644) and write all of data
(composed client-side: open/create + truncate + write).
Sourcepub async fn append(
&self,
path: impl AsRef<Path>,
data: &[u8],
) -> Result<u64, ZeroFsError>
pub async fn append( &self, path: impl AsRef<Path>, data: &[u8], ) -> Result<u64, ZeroFsError>
Append data at end-of-file (open-or-create + fstat + positioned
write, composed client-side); returns the offset where the data landed.
Last-writer-wins under concurrent appenders.
Sourcepub async fn stat(
&self,
path: impl AsRef<Path>,
) -> Result<Metadata, ZeroFsError>
pub async fn stat( &self, path: impl AsRef<Path>, ) -> Result<Metadata, ZeroFsError>
Report the entry at path without following symlinks; anywhere: a
path THROUGH a symlinked directory fails NotADirectory (9P walks are
literal; this applies to every path-taking method). Self::metadata
and Self::canonicalize are the only resolvers.
Sourcepub async fn metadata(
&self,
path: impl AsRef<Path>,
) -> Result<Metadata, ZeroFsError>
pub async fn metadata( &self, path: impl AsRef<Path>, ) -> Result<Metadata, ZeroFsError>
Like Self::stat but resolves symlinks (final AND intermediate
components) client-side (readlink + re-walk), capped at 40 hops.
Sourcepub async fn canonicalize(
&self,
path: impl AsRef<Path>,
) -> Result<PathBuf, ZeroFsError>
pub async fn canonicalize( &self, path: impl AsRef<Path>, ) -> Result<PathBuf, ZeroFsError>
Resolve every symlink in path (40-hop cap) and return the canonical
path, for use with any other method. Lossless: paths are bytes, so a
non-UTF-8 component survives the round trip.
Sourcepub async fn exists(&self, path: impl AsRef<Path>) -> Result<bool, ZeroFsError>
pub async fn exists(&self, path: impl AsRef<Path>) -> Result<bool, ZeroFsError>
True if the path exists (any file type, no symlink following);
NotFound becomes false.
Sourcepub async fn set_attr(
&self,
path: impl AsRef<Path>,
attrs: SetAttrs,
) -> Result<Metadata, ZeroFsError>
pub async fn set_attr( &self, path: impl AsRef<Path>, attrs: SetAttrs, ) -> Result<Metadata, ZeroFsError>
Apply any combination of metadata changes; returns post-change metadata.
Sourcepub async fn chmod(
&self,
path: impl AsRef<Path>,
mode: u32,
) -> Result<Metadata, ZeroFsError>
pub async fn chmod( &self, path: impl AsRef<Path>, mode: u32, ) -> Result<Metadata, ZeroFsError>
Change permission bits.
Sourcepub async fn chown(
&self,
path: impl AsRef<Path>,
uid: Option<u32>,
gid: Option<u32>,
) -> Result<Metadata, ZeroFsError>
pub async fn chown( &self, path: impl AsRef<Path>, uid: Option<u32>, gid: Option<u32>, ) -> Result<Metadata, ZeroFsError>
Change owner and/or group (None leaves a field untouched).
Sourcepub async fn truncate(
&self,
path: impl AsRef<Path>,
size: u64,
) -> Result<Metadata, ZeroFsError>
pub async fn truncate( &self, path: impl AsRef<Path>, size: u64, ) -> Result<Metadata, ZeroFsError>
Truncate or extend a file to size bytes.
Sourcepub async fn set_times(
&self,
path: impl AsRef<Path>,
atime: Option<SetTime>,
mtime: Option<SetTime>,
) -> Result<Metadata, ZeroFsError>
pub async fn set_times( &self, path: impl AsRef<Path>, atime: Option<SetTime>, mtime: Option<SetTime>, ) -> Result<Metadata, ZeroFsError>
Set access/modification times (utimens; None leaves a field untouched).
Sourcepub async fn statfs(&self) -> Result<StatFs, ZeroFsError>
pub async fn statfs(&self) -> Result<StatFs, ZeroFsError>
Filesystem-wide usage and limits.
Sourcepub async fn sync(&self) -> Result<(), ZeroFsError>
pub async fn sync(&self) -> Result<(), ZeroFsError>
Flush to durable (S3-backed) storage. On ZeroFS the server-side flush is filesystem-global, so this is the durability endpoint for write→rename sequences.
Sourcepub async fn create_dir(
&self,
path: impl AsRef<Path>,
mode: u32,
) -> Result<Metadata, ZeroFsError>
pub async fn create_dir( &self, path: impl AsRef<Path>, mode: u32, ) -> Result<Metadata, ZeroFsError>
Create a directory; the parent must exist.
Sourcepub async fn create_dir_all(
&self,
path: impl AsRef<Path>,
mode: u32,
) -> Result<(), ZeroFsError>
pub async fn create_dir_all( &self, path: impl AsRef<Path>, mode: u32, ) -> Result<(), ZeroFsError>
Create a directory and any missing ancestors.
Sourcepub async fn remove_file(
&self,
path: impl AsRef<Path>,
) -> Result<(), ZeroFsError>
pub async fn remove_file( &self, path: impl AsRef<Path>, ) -> Result<(), ZeroFsError>
Remove a file, symlink, or device node.
Sourcepub async fn remove_dir(
&self,
path: impl AsRef<Path>,
) -> Result<(), ZeroFsError>
pub async fn remove_dir( &self, path: impl AsRef<Path>, ) -> Result<(), ZeroFsError>
Remove an empty directory.
Sourcepub async fn remove_dir_all(
&self,
path: impl AsRef<Path>,
) -> Result<(), ZeroFsError>
pub async fn remove_dir_all( &self, path: impl AsRef<Path>, ) -> Result<(), ZeroFsError>
Remove a directory and all its contents, recursively (client-side walk, not atomic).
Sourcepub async fn rename(
&self,
from: impl AsRef<Path>,
to: impl AsRef<Path>,
) -> Result<(), ZeroFsError>
pub async fn rename( &self, from: impl AsRef<Path>, to: impl AsRef<Path>, ) -> Result<(), ZeroFsError>
Atomically rename/move within the filesystem; replaces an existing target.
Sourcepub async fn hard_link(
&self,
original: impl AsRef<Path>,
link: impl AsRef<Path>,
) -> Result<Metadata, ZeroFsError>
pub async fn hard_link( &self, original: impl AsRef<Path>, link: impl AsRef<Path>, ) -> Result<Metadata, ZeroFsError>
Create a hard link at link pointing to the inode of original.
Sourcepub async fn symlink(
&self,
target: impl AsRef<Path>,
link_path: impl AsRef<Path>,
) -> Result<Metadata, ZeroFsError>
pub async fn symlink( &self, target: impl AsRef<Path>, link_path: impl AsRef<Path>, ) -> Result<Metadata, ZeroFsError>
Create a symlink at link_path containing target (stored verbatim,
bytes included).
Sourcepub async fn read_link(
&self,
path: impl AsRef<Path>,
) -> Result<PathBuf, ZeroFsError>
pub async fn read_link( &self, path: impl AsRef<Path>, ) -> Result<PathBuf, ZeroFsError>
Read a symlink target. Lossless: the target is returned byte-for-byte.
Sourcepub async fn mknod(
&self,
path: impl AsRef<Path>,
kind: NodeKind,
mode: u32,
) -> Result<Metadata, ZeroFsError>
pub async fn mknod( &self, path: impl AsRef<Path>, kind: NodeKind, mode: u32, ) -> Result<Metadata, ZeroFsError>
Create a fifo, socket, or device node; mode carries permission bits
only; the type (and device numbers) come from kind.
Sourcepub async fn read_dir(
&self,
path: impl AsRef<Path>,
) -> Result<Vec<DirEntry>, ZeroFsError>
pub async fn read_dir( &self, path: impl AsRef<Path>, ) -> Result<Vec<DirEntry>, ZeroFsError>
List a whole directory (./.. excluded); metadata inline when the
server supports readdirplus.
Sourcepub async fn open_dir(
&self,
path: impl AsRef<Path>,
) -> Result<Arc<Dir>, ZeroFsError>
pub async fn open_dir( &self, path: impl AsRef<Path>, ) -> Result<Arc<Dir>, ZeroFsError>
Open a directory for incremental listing and byte-exact child operations.
Sourcepub async fn open(
&self,
path: impl AsRef<Path>,
opts: OpenOptions,
) -> Result<Arc<File>, ZeroFsError>
pub async fn open( &self, path: impl AsRef<Path>, opts: OpenOptions, ) -> Result<Arc<File>, ZeroFsError>
Open (and optionally create) a file for positioned I/O.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.