Crate watchman_client

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§

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
use watchman_client::prelude::* for convenient access to the types provided by this crate

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 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.
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 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§

ConnectionLost
Error
SubscriptionData
Returned by Subscription::next as events are observed by Watchman.
Value
The Value type is used in cases where the schema is not known statically. As used in Watchman’s protocol, this allows encoding arbitrary metadata that can be passed through the system by eg: the state-enter command, or returned from a saved state storage engine. The values are conceptually equivalent to json values, with the notable difference that BSER can represent a binary byte string value.