Skip to main content

EventFilter

Struct EventFilter 

Source
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

Source

pub fn kind(k: EventKind) -> Self

Convenience: subscribe to a single kind.

Source

pub fn kinds(ks: Vec<EventKind>) -> Self

Convenience: subscribe to a list of kinds.

Source

pub fn any() -> Self

Wildcard: every event.

Source

pub fn with_path_glob(self, glob: GlobSet) -> Self

Builder: AND a path-glob constraint onto this filter.

Source

pub fn with_major_modes(self, modes: Vec<ModeId>) -> Self

Builder: AND a major-mode allowlist onto this filter.

Source

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

Source§

fn clone(&self) -> EventFilter

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EventFilter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EventFilter

Source§

fn default() -> EventFilter

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more