Skip to main content

Crate mountos_native

Crate mountos_native 

Source
Expand description

Blocking client for the mountOS native filesystem API over a Unix socket.

let c = mountos_native::Client::connect("/home/me/.mountOS/sockets/mountos_api_0123456789abcdef.sock")?;
let f = c.open("/a.txt", mountos_native::open_flag::READ_ONLY, 0)?;
let data = f.read_at(0, 4096)?;

The server pushes notices (warm results, watch changes, closing) on the connection that made the call. A reader thread per connection receives them, and Client::add_listener hands every event to your listeners in order. Client::wait_warm and Client::watch build on the same events. With no listener, events go to the logger in Options, or to stderr.

Re-exports§

pub use wire::open_flag;
pub use wire::DirEntry;
pub use wire::FileInfo;
pub use wire::FileType;
pub use wire::Range;
pub use wire::StatfsInfo;

Modules§

frame
Wire frame codec. Mirrors the Go reference in go/frame/frame.go.
wire
Protobuf messages for package mountos.filesystem.v1, generated by build.rs from api/proto/mountos_fs.proto. Method IDs and result types come from the generated ops_gen module, open flags are constants from api/filesystem.yaml.

Structs§

Client
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.
CloneOptions
Settings for clone_entry and clone_dir. Start from CloneOptions::default() and chain the with_ methods.
Dir
An open remote directory. Bound to the connection that opened it, like File.
Event
One event from the server, or a local one (Overflow, ConnectionLost). The client builds it. Callers only read the fields.
File
An open remote file. Calls on one file are serialized by a mutex. Different files on different pool connections run in parallel.
ListenerId
Handle for Client::remove_listener.
OpCounts
Totals an operation reports when it ends.
OpFailure
One entry that failed inside an operation.
OpResult
How an operation ended.
Operation
A running or ended clone_dir or remove_dir. It lives on the connection that started it.
Options
Client settings. Start from Options::default() and chain the with_ methods. New fields can be added in a minor version, so a struct literal does not compile outside this crate.
Watch
A live watch. Iterating blocks until the next event. Only Change and Overflow events of this watch arrive here. When more than 256 events wait, the oldest are dropped and one Overflow event is delivered, which tells the caller to list the path again.
WriteItem
One write in File::write_batch. Build it with WriteItem::new.

Enums§

ChangeKind
How a watched path changed. New kinds can be added, so a match needs a wildcard arm.
CloneOutcome
What clone_entry did with the destination. New outcomes can be added.
Error
Errors returned by the client. New variants can be added, so a match needs a wildcard arm.
EventKind
Kind of an event. New kinds can be added, so a match needs a wildcard arm.
Preserve
Extra properties clone_entry and clone_dir copy from the source. New kinds can be added.

Constants§

DEFAULT_MAX_DIR_ENTRIES
Most entries read_dir_all holds.
DEFAULT_MAX_INFLIGHT
Default for Options::max_inflight.
DEFAULT_MAX_WALK_PENDING
Most directories walk keeps queued for later.
MAX_OP_FAILURES
Most failures an Operation keeps. The server sends at most this many per operation. OpCounts::failed can be larger.

Functions§

socket_path
Computes the native API socket path of the mount at mount_path. mount_path is the path the mount was started with. The result is the same path the mount listens on. Nothing is created or checked on disk.

Type Aliases§

ClientOptions
Alias of Options.
Logger
Receives log lines. The line has no prefix and no newline.
Result
StatResult
Result of one path in Client::stat_batch.