[−][src]Crate watchman_client
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
expr | Working with the watchman expression term syntax |
fields | Defines the fields used in the query result structs |
pdu | This module defines the request and response PDU types used by the watchman protocol. |
prelude |
|
Macros
query_result_type | 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
CanonicalPath | Represents a canonical path in the filesystem. |
Client | A live connection to a watchman server. Use Connector to establish a connection. |
Connector | The Connector defines how to connect to the watchman server.
You will typically use |
ResolvedRoot | 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. |
Subscription | A handle to a subscription initiated via |
Enums
Error | |
SubscriptionData | Returned by Subscription::next as events are observed by Watchman. |