pub struct EventFilter {
pub kinds: Option<Vec<EventKind>>,
pub path_glob: Option<GlobSet>,
pub major_modes: Option<Vec<ModeId>>,
pub minor_modes: Option<Vec<ModeId>>,
pub predicate: Option<EventPredicate>,
}Expand description
Filter applied at publish time. kinds buckets the
subscription; the remaining fields (EF.1) AND-combine on top –
every Some field must match for the event to be delivered, a
None field is unconstrained. Mode activation
(mode-architecture.md §7.4) is the caller these reserved fields
were declared for.
Fields§
§kinds: Option<Vec<EventKind>>Kinds this subscription cares about. None means “all
kinds” – the wildcard. Callers should always pass
Some(...) to keep dispatch indexed; the wildcard is
supported for one-off debugging / introspection sinks.
path_glob: Option<GlobSet>Restrict to events whose path matches this set (e.g.
**/*.rs for a Rust major-mode resolver). None is
unconstrained. Events with no path (e.g. BeforeQuit,
scratch-buffer opens) never match a Some glob. Build the
set via crate::compile_glob_set.
major_modes: Option<Vec<ModeId>>Restrict to events whose buffer is in one of these major
modes – the minor-mode allowlist of §7.4. None is
unconstrained. No Event variant carries a major mode yet
(MA.1 lands MajorEntered { major }); until then a Some
allowlist matches nothing, which is the correct semantics
for “only fire inside these majors.”
minor_modes: Option<Vec<ModeId>>Restrict to minor-mode lifecycle events naming one of these
minors — the peer of Self::major_modes, and the reason it
cannot simply reuse it.
MinorActivated / MinorDeactivated carry the MINOR’s name,
so event_major_mode answers None for them and a
major_modes-constrained filter rejects every one. Before this
field a subscriber that wanted one specific minor had no
declarative way to say so: it subscribed unfiltered and compared
names in its handler, which for a plugin means waking its task
for every minor activation in every buffer to do nothing.
Deliberately a SEPARATE field rather than one merged modes
list. There are far more minors than majors and the two ask
different questions — major_modes means “the buffer is
entering one of these majors” (§7.4’s minor-activation
allowlist), while this means “this specific minor turned on”.
A merged field would answer both at once and let a subscription
fire on a name collision between the two namespaces.
None is unconstrained. Both constrained is an AND, and since
no event carries both names it matches nothing — which is the
honest reading of “a major event AND a minor event”.
predicate: Option<EventPredicate>Escape-hatch predicate. None is unconstrained. See
EventPredicate for the locking contract – it runs under
the bus mutex and must not re-enter the bus.
Implementations§
Source§impl EventFilter
impl EventFilter
Sourcepub fn with_path_glob(self, glob: GlobSet) -> Self
pub fn with_path_glob(self, glob: GlobSet) -> Self
Builder: AND a path-glob constraint onto this filter.
Sourcepub fn with_major_modes(self, modes: Vec<ModeId>) -> Self
pub fn with_major_modes(self, modes: Vec<ModeId>) -> Self
Builder: AND a major-mode allowlist onto this filter.
Sourcepub fn with_predicate(self, predicate: EventPredicate) -> Self
pub fn with_predicate(self, predicate: EventPredicate) -> Self
Builder: AND an escape-hatch predicate onto this filter. See
EventPredicate for the locking contract.
Trait Implementations§
Source§impl Clone for EventFilter
impl Clone for EventFilter
Source§fn clone(&self) -> EventFilter
fn clone(&self) -> EventFilter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more