pub struct Client { /* private fields */ }Expand description
Client for one mount. Cheap to clone, clones share the pool, the listeners and the event
dispatcher. The last clone to drop closes everything. close does it at once for all clones.
Implementations§
Source§impl Client
impl Client
Sourcepub fn stat_batch(&self, paths: &[String]) -> Result<Vec<StatResult>>
pub fn stat_batch(&self, paths: &[String]) -> Result<Vec<StatResult>>
Returns attributes for many paths. The result has one entry per path in input order. Large inputs are split into several requests that run in parallel on the pool.
Source§impl Client
impl Client
Sourcepub fn connect(path: impl AsRef<Path>) -> Result<Client>
pub fn connect(path: impl AsRef<Path>) -> Result<Client>
Connects with default options (4 connections).
Sourcepub fn connect_with(path: impl AsRef<Path>, opts: Options) -> Result<Client>
pub fn connect_with(path: impl AsRef<Path>, opts: Options) -> Result<Client>
Connects with the given options. The first connection and handshake happen now, so a bad socket or version mismatch fails here.
Sourcepub fn close(&self)
pub fn close(&self)
Ends all connections, watches and background threads. Later calls fail with an I/O error
of kind ConnectionAborted. Dropping the last clone does the same.
Sourcepub fn open(&self, path: &str, flags: u32, mode: u32) -> Result<File>
pub fn open(&self, path: &str, flags: u32, mode: u32) -> Result<File>
Opens a file. flags combine open_flag values. The file stays bound to the connection that opened it.
Sourcepub fn utimens(
&self,
path: &str,
atime_ns: Option<i64>,
mtime_ns: Option<i64>,
) -> Result<()>
pub fn utimens( &self, path: &str, atime_ns: Option<i64>, mtime_ns: Option<i64>, ) -> Result<()>
Sets times in nanoseconds since the epoch. None leaves that time unchanged.
Source§impl Client
impl Client
Sourcepub fn add_listener(
&self,
f: impl Fn(&Event) + Send + Sync + 'static,
) -> ListenerId
pub fn add_listener( &self, f: impl Fn(&Event) + Send + Sync + 'static, ) -> ListenerId
Adds a listener. Every listener gets every event, in order, on the dispatcher thread of
this client. The call must return quickly. A slow listener makes the queue (1024 events)
drop its oldest events, and every listener then gets one local Overflow event.
A panic in a listener is caught and logged. With no listener, events go to the logger.
A listener that holds a Client clone keeps the client open until close is called.
Sourcepub fn remove_listener(&self, id: ListenerId)
pub fn remove_listener(&self, id: ListenerId)
Removes a listener. An unknown id does nothing.
Sourcepub fn wait_warm(&self, id: u64, timeout: Duration) -> Result<()>
pub fn wait_warm(&self, id: u64, timeout: Duration) -> Result<()>
Waits until warm request id is done. A failed warm returns its failure as Error::Server.
Waiting longer than timeout returns an I/O error of kind TimedOut. The client keeps the
last 1024 finished warms, so a warm that ended before this call is not missed. The server
is not polled.
Source§impl Client
impl Client
Sourcepub fn lstat(&self, path: &str) -> Result<FileInfo>
pub fn lstat(&self, path: &str) -> Result<FileInfo>
Returns attributes for path without following a final symlink.
Sourcepub fn symlink(&self, target: &str, link_path: &str) -> Result<()>
pub fn symlink(&self, target: &str, link_path: &str) -> Result<()>
Creates link_path pointing at target.
Sourcepub fn readlink(&self, path: &str) -> Result<String>
pub fn readlink(&self, path: &str) -> Result<String>
Returns the target of the symlink at path.
Sourcepub fn link(&self, existing: &str, new_path: &str) -> Result<()>
pub fn link(&self, existing: &str, new_path: &str) -> Result<()>
Creates new_path as a hard link to existing.
Sourcepub fn statfs(&self, path: &str) -> Result<StatfsInfo>
pub fn statfs(&self, path: &str) -> Result<StatfsInfo>
Returns capacity figures for the filesystem holding path.
Sourcepub fn access(&self, path: &str, mode: u32) -> Result<()>
pub fn access(&self, path: &str, mode: u32) -> Result<()>
Checks permissions for path. mode is a bit mask of 4 (read), 2 (write), 1 (execute), or 0 (exists).
Sourcepub fn remove_all(&self, path: &str) -> Result<u64>
pub fn remove_all(&self, path: &str) -> Result<u64>
Removes path and everything below it. Returns the removed entry count.
Source§impl Client
impl Client
Sourcepub fn read_dir_all(&self, path: &str) -> Result<Vec<DirEntry>>
pub fn read_dir_all(&self, path: &str) -> Result<Vec<DirEntry>>
Lists one directory completely by following the ls cursor. Fails with
Error::TooManyEntries when the directory has more than DEFAULT_MAX_DIR_ENTRIES entries.
Sourcepub fn read_dir_all_max(
&self,
path: &str,
max_entries: usize,
) -> Result<Vec<DirEntry>>
pub fn read_dir_all_max( &self, path: &str, max_entries: usize, ) -> Result<Vec<DirEntry>>
Like read_dir_all with a caller-chosen entry limit.
Sourcepub fn walk(
&self,
path: &str,
f: impl FnMut(&str, &DirEntry) -> Result<()>,
) -> Result<()>
pub fn walk( &self, path: &str, f: impl FnMut(&str, &DirEntry) -> Result<()>, ) -> Result<()>
Visits every entry below path, depth first. f gets the directory path and the entry,
which carries its attributes. The entries of a directory arrive in listing order and each
subdirectory is visited after the directory that holds it. Symlinks are reported and not
followed. The walk stops at the first error from ls or from f and returns it. No entry
is skipped silently. The walk holds one page plus the queued directories, at most
DEFAULT_MAX_WALK_PENDING, and fails with Error::TooManyEntries beyond that.