Struct biodivine_sketchbook::app::state::_state_app::AppState
source · pub struct AppState {
session_state: Mutex<HashMap<String, DynSession>>,
window_to_session: Mutex<HashMap<String, String>>,
}
Expand description
AppState implements mapping between session IDs and session objects.
Specifically, it ensures:
- Synchronization by locking the app state.
- Ability to add/remove windows as they are opened/closed.
- Error handling and retransmission of events.
As such, AppState does not actually implement the super::SessionState trait.
Fields§
§session_state: Mutex<HashMap<String, DynSession>>
§window_to_session: Mutex<HashMap<String, String>>
Implementations§
source§impl AppState
impl AppState
sourcepub fn session_created(&self, id: &str, session: impl Into<DynSession>)
pub fn session_created(&self, id: &str, session: impl Into<DynSession>)
Register the newly created session to the AppState.
sourcepub fn window_created(&self, id: &str, session_id: &str)
pub fn window_created(&self, id: &str, session_id: &str)
Register the newly created window to the corresponding session in the AppState.
sourcepub fn get_session_id(&self, window: &Window) -> String
pub fn get_session_id(&self, window: &Window) -> String
Get the ID of the session that owns given Window.
sourcepub fn get_windows_for_session(&self, session_id: &str) -> Vec<String>
pub fn get_windows_for_session(&self, session_id: &str) -> Vec<String>
Get IDs of all windows corresponding to a given session.
sourcepub fn emit_to_session_windows(
&self,
app: &AeonApp,
session_id: &str,
state_change: StateChange,
) -> Result<(), DynError>
pub fn emit_to_session_windows( &self, app: &AeonApp, session_id: &str, state_change: StateChange, ) -> Result<(), DynError>
Emit state change events to all front-end windows corresponding to a given session.
pub fn consume_event( &self, app: &AeonApp, session_id: &str, action: &UserAction, ) -> Result<(), DynError>
pub fn consume_message( &self, app: &AeonApp, session_to_id: &str, session_from_id: &str, message: &SessionMessage, ) -> Result<(), DynError>
pub fn refresh( &self, app: &AeonApp, session_id: &str, full_path: &[String], ) -> Result<(), DynError>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AppState
impl RefUnwindSafe for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnwindSafe for AppState
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more