Crate watchman_client
source · [−]Expand description
This crate provides a client to the watchman file watching service.
Start with the Connector struct and use it to connect and return a Client struct, Client::resolve_root to resolve a path and initiate a watch, and then Client::query to perform a query, or Client::subscribe to subscribe to file changes in real time.
This example shows how to connect and expand a glob from the current working directory:
use watchman_client::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut client = Connector::new().connect().await?;
let resolved = client
.resolve_root(CanonicalPath::canonicalize(".")?)
.await?;
// Basic globs -> names
let files = client.glob(&resolved, &["**/*.rs"]).await?;
println!("files: {:#?}", files);
Ok(())
}
Modules
Working with the watchman expression term syntax
Defines the fields used in the query result structs
This module defines the request and response PDU types used by the watchman protocol.
use watchman_client::prelude::*
for convenient access to the types
provided by this crate
Macros
A macro to help define a type to hold file information from a query. This macro enables a type-safe way to define the set of fields to be returned and de-serialize only those fields.
Structs
Represents a canonical path in the filesystem.
The Connector defines how to connect to the watchman server.
You will typically use Connector::new
to set up the connection with
the environmental defaults. You might want to override those defaults
in situations such as integration testing environments, or in extremely
latency sensitive environments where the cost of performing discovery
is a measurable overhead.
Data that describes a watched filesystem location. Watchman performs watch aggregation to project boundaries, so a request to watch a subdirectory will resolve to the higher level root path and a relative path offset. This struct encodes both pieces of information.
A handle to a subscription initiated via Client::subscribe
.
Repeatedly call Subscription::next().await
to yield the next
set of subscription results.
Use the cancel
method to gracefully halt this subscription
if you have a program that creates and destroys subscriptions
throughout its lifetime.
Enums
Returned by Subscription::next as events are observed by Watchman.