Trait gravel_ffi::Hit

source ·
pub trait Hit: Debug + Send + Sync {
    // Required methods
    fn title<'_self>(&'_self self) -> RStr<'_self>;
    fn action(&self, context: RefDynHitActionContext<'_>);

    // Provided methods
    fn subtitle<'_self>(&'_self self) -> RStr<'_self> { ... }
    fn override_score(&self) -> ROption<u32> { ... }
    fn secondary_action(&self, context: RefDynHitActionContext<'_>) { ... }
}
Expand description

This is the trait for hits returned from crate::Providers.

It must contain some information about the hit, as well as a function to execute when it is selected.

For most situations, a SimpleHit is sufficient.

Required Methods§

source

fn title<'_self>(&'_self self) -> RStr<'_self>

source

fn action(&self, context: RefDynHitActionContext<'_>)

Provided Methods§

source

fn subtitle<'_self>(&'_self self) -> RStr<'_self>

source

fn override_score(&self) -> ROption<u32>

If ROption::RSome, skips normal scoring for this hit, instead using the contained score as-is.

This is useful for pinning a hit to the top or bottom of the results, but probably not very useful for actual scoring, as the underlying scoring implementation used in gravel may change.

source

fn secondary_action(&self, context: RefDynHitActionContext<'_>)

Secondary action for related functionality.

How this is triggered and what it does is plugin-defined. By default, it calls the regular action.

Implementors§