macro_rules! query_result_type {
    (
    $struct_vis:vis struct $tyname:ident {
        $($field_vis:vis $field_name:ident : $field_ty:ty),+ $(,)?
    }
    ) => { ... };
}
Expand description

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.

This defines a struct that will receive the name and content hash fields from the results. When used together with Client::query, the query will automatically use the appropriate list of field names:

use watchman_client::prelude::*;
use serde::Deserialize;

query_result_type! {
    struct NameAndHash {
        name: NameField,
        hash: ContentSha1HexField,
    }
}

The struct must consist of 2 or more fields; the macro subsystem won’t allow for generating an appropriate type definition for a single field result.

If you need only a single field, look at NameOnly.

The field types must implement an undocumented trait that enables the automatic field naming and correct deserialization regardless of the field name in the struct. As such, you should consider the set of fields to be limited to those provided by this crate.