Struct SearchPage

Source
pub struct SearchPage<'a, T> {
    pub items: Vec<T>,
    pub item_callback: Box<dyn RustofiCallback<T>>,
    pub blank_callback: Box<dyn FnMut() -> RustofiResult>,
    pub actions: Vec<String>,
    pub action_callback: Box<dyn FnMut(&String) -> RustofiResult>,
    pub search_callback: Box<dyn FnMut(&String) -> RustofiResult>,
    pub window: Window<'a>,
}
Expand description

SearchPage displays a multi column rofi window and is meant to be used as a search page of sorts for your application. items should be associated with a data model, while actions should be either operations you can perform on those items, or actions you can take within the app (switch pages for example). The search_callback allows you to refresh the data models displayed or perform an operation on custom entry

Fields§

§items: Vec<T>

standard list items, will be displayed in the rofi window using to_string()

§item_callback: Box<dyn RustofiCallback<T>>

callback called whenever an item in the items vector is selected

§blank_callback: Box<dyn FnMut() -> RustofiResult>

callback called whenever a blank entry is selected

§actions: Vec<String>

additional action entries, meant to be operations on standard items

§action_callback: Box<dyn FnMut(&String) -> RustofiResult>

callback called whenever a custom action is selected (NOT on Exit or Cancel)

§search_callback: Box<dyn FnMut(&String) -> RustofiResult>

callback to be run when no other entry matches

§window: Window<'a>

rofi window instance

Implementations§

Source§

impl<'a, T: Display + Clone> SearchPage<'a, T>

Source

pub fn new( items: Vec<T>, item_callback: Box<dyn RustofiCallback<T>>, search_callback: Box<dyn FnMut(&String) -> RustofiResult>, ) -> Self

create the initial bare minumum AppPage, without showing the window yet

Trait Implementations§

Source§

impl<'a, T: Display + Clone> RustofiComponent<'a> for SearchPage<'a, T>

Source§

fn create_window() -> Window<'a>

create a rofi window with 4 columns

Source§

fn action(self, acb: Box<dyn FnMut(&String) -> RustofiResult>) -> Self

set the callback to be run when an action is selected

Source§

fn blank(self, bcb: Box<dyn FnMut() -> RustofiResult>) -> Self

set the callback to be run when the blank entry is selected

Source§

fn actions(self, actions: Vec<String>) -> Self

set the actions in the AppPage. This should only be called once as it overwrites the previous settings

Source§

fn window(self, window: Window<'a>) -> Self

set a completely custom window

Source§

fn display(&mut self, prompt: String) -> RustofiResult

display the search window and match the entry against the actions, standard items and finally if nothing matches, run the search callback

Auto Trait Implementations§

§

impl<'a, T> Freeze for SearchPage<'a, T>

§

impl<'a, T> !RefUnwindSafe for SearchPage<'a, T>

§

impl<'a, T> !Send for SearchPage<'a, T>

§

impl<'a, T> !Sync for SearchPage<'a, T>

§

impl<'a, T> Unpin for SearchPage<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for SearchPage<'a, T>

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