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::Provider
s.
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§
fn title<'_self>(&'_self self) -> RStr<'_self>
fn action(&self, context: RefDynHitActionContext<'_>)
Provided Methods§
fn subtitle<'_self>(&'_self self) -> RStr<'_self>
sourcefn override_score(&self) -> ROption<u32>
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.
sourcefn secondary_action(&self, context: RefDynHitActionContext<'_>)
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.