Struct EntryRenderData

Source
pub struct EntryRenderData<'a> {
    pub illegal_char_for_hotkey: Option<char>,
    pub kind: &'a EntryKind,
    pub key_combo_sequence: Option<Vec<KeyCombo>>,
    /* private fields */
}
Expand description

This struct represents the data that will be used to render an entry in the list. It is used in conjunction with the search query to determine how to render the entry.

It holds the prefix, search hit and suffix of the entry name, the next character after the search hit, the kind of the entry and the shortcut assigned to the entry.

This allows us to render the entry in the UI with the search hit underlined and the shortcut displayed next to the entry.

For example, if the entry name is “Cargo.toml” and the search query is “ar”, the prefix will be “C”, the search hit will be “ar”, the suffix will be “go.toml”, the next character will be “g” (the character immediately after the search hit)

The shortcut is assigned at a later stage and is used to quickly jump to the entry.

Fields§

§illegal_char_for_hotkey: Option<char>

The character that shouldn’t appear in a hotkey sequence for the entry. That’s normally the first character of the name or first character after the search hit. The idea is to allow the user to be able finish writing out the entry name without jumping to the entry itself.

NOTE: that the character is converted to lowercase before being stored, since our search is case insensitive.

§kind: &'a EntryKind

The kind of the entry, we need to keep track of this because we render directories differently than files.

§key_combo_sequence: Option<Vec<KeyCombo>>

The key combo sequence assigned to the entry, it’s an optional sequence of key combos.

Implementations§

Source§

impl EntryRenderData<'_>

Source

pub fn from_entry<T: AsRef<str>>( entry: &Entry, search_query: T, ) -> EntryRenderData<'_>

Trait Implementations§

Source§

impl<'a> Debug for EntryRenderData<'a>

Source§

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

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

impl<'a> From<EntryRenderData<'a>> for ListItem<'a>

Source§

fn from(value: EntryRenderData<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> PartialEq for EntryRenderData<'a>

Source§

fn eq(&self, other: &EntryRenderData<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> StructuralPartialEq for EntryRenderData<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for EntryRenderData<'a>

§

impl<'a> RefUnwindSafe for EntryRenderData<'a>

§

impl<'a> Send for EntryRenderData<'a>

§

impl<'a> Sync for EntryRenderData<'a>

§

impl<'a> Unpin for EntryRenderData<'a>

§

impl<'a> UnwindSafe for EntryRenderData<'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.