StateCoordinator

Struct StateCoordinator 

Source
pub struct StateCoordinator {
    pub state_container: AppStateContainer,
    pub shadow_state: Rc<RefCell<ShadowStateManager>>,
    pub viewport_manager: Rc<RefCell<Option<ViewportManager>>>,
    pub hybrid_parser: HybridParser,
}
Expand description

StateCoordinator manages and synchronizes all state components in the TUI This centralizes state management and reduces coupling in the main TUI

Fields§

§state_container: AppStateContainer

Core application state

§shadow_state: Rc<RefCell<ShadowStateManager>>

Shadow state for tracking mode transitions

§viewport_manager: Rc<RefCell<Option<ViewportManager>>>

Viewport manager for display state

§hybrid_parser: HybridParser

SQL parser with schema information

Implementations§

Source§

impl StateCoordinator

Source

pub fn sync_mode_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, mode: AppMode, trigger: &str, )

Static version of sync_mode that works with references

Source

pub fn update_parser_with_refs( state_container: &AppStateContainer, parser: &mut HybridParser, )

Static version of update_parser_for_current_buffer

Source

pub fn new( state_container: AppStateContainer, shadow_state: Rc<RefCell<ShadowStateManager>>, viewport_manager: Rc<RefCell<Option<ViewportManager>>>, hybrid_parser: HybridParser, ) -> Self

Source

pub fn sync_mode(&mut self, mode: AppMode, trigger: &str)

Synchronize mode across all state containers This ensures AppStateContainer, Buffer, and ShadowState are all in sync

Source

pub fn set_mode_via_shadow_state(&mut self, mode: AppMode, trigger: &str)

Alternative mode setter that goes through shadow state

Source

pub fn sync_after_buffer_switch(&mut self)

Synchronize all state after buffer switch This should be called after any buffer switch operation

Source

pub fn update_parser_for_current_buffer(&mut self)

Update parser schema from current buffer’s DataView

Source

pub fn enter_search_mode(&mut self, mode: SearchMode) -> String

Enter a search mode with proper state synchronization

Cancel search and properly restore state This handles all the complex state synchronization when Escape is pressed during search

Source

pub fn cancel_search_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, vim_search_adapter: Option<&RefCell<VimSearchAdapter>>, )

Static version for delegation pattern with vim search adapter

Source

pub fn should_handle_next_match( state_container: &AppStateContainer, vim_search_adapter: Option<&RefCell<VimSearchAdapter>>, ) -> bool

Check if ‘n’ key should navigate to next search match Returns true only if there’s an active search (not cancelled with Escape)

Source

pub fn should_handle_previous_match( state_container: &AppStateContainer, vim_search_adapter: Option<&RefCell<VimSearchAdapter>>, ) -> bool

Check if ‘N’ key should navigate to previous search match Returns true only if there’s an active search (not cancelled with Escape)

Source

pub fn complete_search_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, vim_search_adapter: Option<&RefCell<VimSearchAdapter>>, mode: AppMode, trigger: &str, )

Complete a search operation (after Apply/Enter is pressed) This keeps the pattern for n/N navigation but marks search as complete

Source

pub fn apply_text_filter_with_refs( state_container: &mut AppStateContainer, pattern: &str, ) -> usize

Apply text filter and coordinate all state updates Returns the number of matching rows

Source

pub fn apply_fuzzy_filter_with_refs( state_container: &mut AppStateContainer, viewport_manager: &RefCell<Option<ViewportManager>>, ) -> (usize, Vec<usize>)

Apply fuzzy filter and coordinate all state updates Returns (match_count, filter_indices)

Source

pub fn reset_table_state_with_refs( state_container: &mut AppStateContainer, viewport_manager: &RefCell<Option<ViewportManager>>, )

Reset all table-related state to initial values This is typically called when switching data sources or after queries

Source

pub fn add_dataview_with_refs( state_container: &mut AppStateContainer, viewport_manager: &RefCell<Option<ViewportManager>>, dataview: DataView, source_name: &str, config: &Config, ) -> Result<(), Error>

Add a new DataView and coordinate all necessary state updates This centralizes the complex logic of adding a new data source

Source

pub fn set_sql_query_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, parser: &mut HybridParser, table_name: &str, raw_table_name: &str, config: &Config, ) -> String

Set SQL query and update all related state This centralizes the complex logic of setting up SQL query state

Source

pub fn handle_execute_query_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, query: &str, ) -> Result<bool, Error>

Handle query execution and all related state changes Returns true if application should exit

Source

pub fn switch_to_results_after_query(&mut self)

Switch to Results mode after successful query execution

Source

pub fn switch_to_results_after_query_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, )

Static version for delegation

Source

pub fn apply_filter_search_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, pattern: &str, )

Apply filter search with proper state coordination

Source

pub fn apply_fuzzy_filter_search_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, pattern: &str, )

Apply fuzzy filter search with proper state coordination

Source

pub fn apply_column_search_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, pattern: &str, )

Apply column search with proper state coordination

Source

pub fn start_history_search_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, current_input: String, ) -> (String, usize)

Start history search with proper state transitions

Source

pub fn goto_first_row_with_refs( state_container: &mut AppStateContainer, vim_search_adapter: Option<&RefCell<VimSearchAdapter>>, viewport_manager: Option<&RefCell<Option<ViewportManager>>>, )

Coordinate goto first row with vim search state

Source

pub fn goto_last_row_with_refs(state_container: &mut AppStateContainer)

Coordinate goto last row

Source

pub fn goto_row_with_refs(state_container: &mut AppStateContainer, row: usize)

Coordinate goto specific row

Source

pub fn state_container(&self) -> &AppStateContainer

Get reference to AppStateContainer

Source

pub fn state_container_mut(&mut self) -> &mut AppStateContainer

Get mutable reference to AppStateContainer

Source

pub fn current_buffer(&self) -> Option<&Buffer>

Get reference to current buffer

Source

pub fn current_buffer_mut(&mut self) -> Option<&mut Buffer>

Get mutable reference to current buffer

Source

pub fn buffers(&self) -> &BufferManager

Get reference to buffer manager

Source

pub fn buffers_mut(&mut self) -> &mut BufferManager

Get mutable reference to buffer manager

Source

pub fn parser(&self) -> &HybridParser

Get reference to hybrid parser

Source

pub fn parser_mut(&mut self) -> &mut HybridParser

Get mutable reference to hybrid parser

Auto Trait Implementations§

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,