Struct SelectionExternalStorage

Source
pub struct SelectionExternalStorage<'f, Storage> { /* private fields */ }
Expand description

MultiSelectStorage that forwards the selection data to another place.

Storage is the inner storage type, usually a mutable reference, but not necessarily. 'f is the lifetime of the setter function, usually 'static.

Implementations§

Source§

impl<'f, Storage> SelectionExternalStorage<'f, Storage>

Source

pub fn new( storage: Storage, selection_size: impl Fn(&Storage) -> Option<usize> + 'f, setter: impl FnMut(&mut Storage, usize, bool) + 'f, ) -> Self

Creates a new SelectionExternalStorage.

The intended usage is that you keep the storage in your code and when multi-select happens, you pass a mutable reference to it in storage, along with a setter function to set the selection status of an item.

Additionally, pass a function to count the number of selected items. If you don’t want to compute that, use |_| None.

Source

pub fn storage(&mut self) -> &mut Storage

Gets a reference to the inner storage.

Source

pub fn into_storage(self) -> Storage

Unwraps the inner storage.

Trait Implementations§

Source§

impl<'f, Storage> MultiSelectStorage for SelectionExternalStorage<'f, Storage>

Source§

fn size(&self) -> Option<usize>

Source§

fn apply_requests(&mut self, ms: &mut MultiSelect)

Auto Trait Implementations§

§

impl<'f, Storage> Freeze for SelectionExternalStorage<'f, Storage>
where Storage: Freeze,

§

impl<'f, Storage> !RefUnwindSafe for SelectionExternalStorage<'f, Storage>

§

impl<'f, Storage> !Send for SelectionExternalStorage<'f, Storage>

§

impl<'f, Storage> !Sync for SelectionExternalStorage<'f, Storage>

§

impl<'f, Storage> Unpin for SelectionExternalStorage<'f, Storage>
where Storage: Unpin,

§

impl<'f, Storage> !UnwindSafe for SelectionExternalStorage<'f, Storage>

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.