Skip to main content

Filterable

Derive Macro Filterable 

Source
#[derive(Filterable)]
{
    // Attributes available to this derive:
    #[filterable]
}
Expand description

Derive a stable typed filter schema for a named struct.

The required target is the stable name embedded in portable expressions. Every supported field produces one member of the generated <Type>Fields companion. Bring renamed_libtmux::query::Filterable into scope to call filter_fields.

Enable the core crate’s derive feature and use its root Filterable re-export. A deliberate direct dependency on libtmux-macros must exactly match the libtmux version because the expansion uses a hidden core ABI.

§Examples

use renamed_libtmux::Filterable;
use renamed_libtmux::query::{Filterable as _, QueryIteratorExt as _};

#[derive(Filterable)]
#[filterable(target = "task")]
struct Task {
    name: String,
    done: bool,
}

let values = vec![
    Task { name: "build".into(), done: false },
    Task { name: "test".into(), done: true },
];
let fields = Task::filter_fields();
let expression = fields.name.contains("ui").and(fields.done.eq(false));
let selected = values.iter().matching(&expression).collect::<Vec<_>>();
assert_eq!(selected.len(), 1);