pub struct SearchKey {
pub text: String,
pub kind: KeyKind,
pub weight: i32,
pub case_fold_only: bool,
pub source_map: Option<Box<[Option<SourceSpan>]>>,
}Expand description
One searchable form for a candidate.
Fields§
§text: StringText that the matcher scores against query variants.
kind: KeyKindSemantic key type used for query compatibility checks.
weight: i32Score adjustment for this key type.
case_fold_only: boolTrue when case folding alone reproduces this key from the candidate’s display text,
which makes the key redundant for a case-insensitive search whose matcher folds case
the same way (see crate::MatcherBackend::folds_case). A matcher that does not
claim to fold case is still offered the key.
source_map: Option<Box<[Option<SourceSpan>]>>Optional map from key character positions back to original source spans.
Implementations§
Source§impl SearchKey
impl SearchKey
Sourcepub fn new(kind: KeyKind, text: impl Into<String>) -> Self
pub fn new(kind: KeyKind, text: impl Into<String>) -> Self
Creates a search key using the default weight for its kind.
Sourcepub fn default_weight(kind: KeyKind) -> i32
pub fn default_weight(kind: KeyKind) -> i32
Returns the default score adjustment for a key kind.
Sourcepub fn with_case_fold_only(self, case_fold_only: bool) -> Self
pub fn with_case_fold_only(self, case_fold_only: bool) -> Self
Marks whether case folding alone reproduces this key from the display text.
Sourcepub fn with_source_map(self, source_map: Vec<Option<SourceSpan>>) -> Self
pub fn with_source_map(self, source_map: Vec<Option<SourceSpan>>) -> Self
Attaches a source map to this key.
Sourcepub fn normalized(text: impl Into<String>) -> Self
pub fn normalized(text: impl Into<String>) -> Self
Creates a normalized-display search key.
Sourcepub fn kana_reading(text: impl Into<String>) -> Self
pub fn kana_reading(text: impl Into<String>) -> Self
Creates a Japanese kana-reading search key.
Sourcepub fn romaji_reading(text: impl Into<String>) -> Self
pub fn romaji_reading(text: impl Into<String>) -> Self
Creates a Japanese romaji-reading search key.
Sourcepub fn pinyin_full(text: impl Into<String>) -> Self
pub fn pinyin_full(text: impl Into<String>) -> Self
Creates a Chinese pinyin search key with separated syllables.
Sourcepub fn pinyin_joined(text: impl Into<String>) -> Self
pub fn pinyin_joined(text: impl Into<String>) -> Self
Creates a Chinese pinyin search key with syllables joined.
Sourcepub fn pinyin_initials(text: impl Into<String>) -> Self
pub fn pinyin_initials(text: impl Into<String>) -> Self
Creates a Chinese pinyin initials search key.
Sourcepub fn korean_romanized(text: impl Into<String>) -> Self
pub fn korean_romanized(text: impl Into<String>) -> Self
Creates a Korean romanized Hangul search key.
Sourcepub fn korean_initials(text: impl Into<String>) -> Self
pub fn korean_initials(text: impl Into<String>) -> Self
Creates a Korean initial-consonant search key.
Sourcepub fn korean_keyboard(text: impl Into<String>) -> Self
pub fn korean_keyboard(text: impl Into<String>) -> Self
Creates a Korean keyboard-layout search key.
Sourcepub fn learned_alias(text: impl Into<String>) -> Self
pub fn learned_alias(text: impl Into<String>) -> Self
Creates a user-learned alias search key.
Trait Implementations§
impl Eq for SearchKey
impl StructuralPartialEq for SearchKey
Auto Trait Implementations§
impl Freeze for SearchKey
impl RefUnwindSafe for SearchKey
impl Send for SearchKey
impl Sync for SearchKey
impl Unpin for SearchKey
impl UnsafeUnpin for SearchKey
impl UnwindSafe for SearchKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more