Skip to main content

StateCommon

Trait StateCommon 

Source
pub trait StateCommon {
    type ModelType;
    type TagType: ToString;
    type KeyType: Clone;

    // Required methods
    fn get_filter_info(&self) -> &Option<(Self::TagType, String)>;
    fn get_tag_from_tab_idx(&self, tab: &str, idx: usize) -> Self::TagType;
    fn get_model(&self) -> Ref<'_, Self::ModelType>;
    fn get_model_mut(&self) -> RefMut<'_, Self::ModelType>;
    fn new(model: Rc<RefCell<Self::ModelType>>) -> Self;

    // Provided methods
    fn is_filter_supported_from_tab_idx(&self, _tab: &str, _idx: usize) -> bool { ... }
    fn set_filter_from_tab_idx(
        &mut self,
        _tab: &str,
        _idx: usize,
        _filter: Option<String>,
    ) -> bool { ... }
    fn set_sort_tag(&mut self, _tag: Self::TagType, _reverse: &mut bool) -> bool { ... }
    fn set_sort_string(&mut self, _selection: &str, _reverse: &mut bool) -> bool { ... }
    fn set_sort_tag_from_tab_idx(
        &mut self,
        _tab: &str,
        _idx: usize,
        _reverse: &mut bool,
    ) -> bool { ... }
}
Expand description

A trait that defines common state data querying or event handling.

This trait must be implemented by all view state. It will help to expose state data to the StatsView for common behavior. On the other hand, it force a view to have required data in order to fit itself inside the StatsView.

Required Associated Types§

Required Methods§

Source

fn get_filter_info(&self) -> &Option<(Self::TagType, String)>

Expose filter data for StatsView to set fields in filter popup

Source

fn get_tag_from_tab_idx(&self, tab: &str, idx: usize) -> Self::TagType

Gets the FieldId associated with given tab and column index

Source

fn get_model(&self) -> Ref<'_, Self::ModelType>

Source

fn get_model_mut(&self) -> RefMut<'_, Self::ModelType>

Source

fn new(model: Rc<RefCell<Self::ModelType>>) -> Self

Provided Methods§

Source

fn is_filter_supported_from_tab_idx(&self, _tab: &str, _idx: usize) -> bool

Returns true iff filtering is supported for column

Source

fn set_filter_from_tab_idx( &mut self, _tab: &str, _idx: usize, _filter: Option<String>, ) -> bool

Set the filter (current column and filter string) Return true on success, false on failure

Source

fn set_sort_tag(&mut self, _tag: Self::TagType, _reverse: &mut bool) -> bool

Set the sorting tag to common state Return true on success, false if current tab doest support sorting.

Source

fn set_sort_string(&mut self, _selection: &str, _reverse: &mut bool) -> bool

Source

fn set_sort_tag_from_tab_idx( &mut self, _tab: &str, _idx: usize, _reverse: &mut bool, ) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§