pub struct CoreState { /* private fields */ }Expand description
The central state machine for an Extro extension.
Owns all domain state and provides deterministic command dispatch.
JavaScript never mutates this directly — it sends CoreCommands
and receives CoreResults.
§Example
use extro_core::*;
let mut state = CoreState::new();
let command = CoreCommand {
surface: RuntimeSurface::Popup,
action: CoreAction::SyncState,
snapshot: BrowserSnapshot {
url: "https://example.com".into(),
title: "Example".into(),
selected_text: None,
},
};
let result = state.dispatch(command);
assert_eq!(result.message, "State synchronized");Implementations§
Source§impl CoreState
impl CoreState
Sourcepub fn dispatch(&mut self, command: CoreCommand) -> CoreResult
pub fn dispatch(&mut self, command: CoreCommand) -> CoreResult
Dispatch a command and return the result with any side effects.
This is the main entry point for all extension logic. Each command increments the session counter and appends to the internal log.
Sourcepub fn telemetry(&self) -> Vec<String>
pub fn telemetry(&self) -> Vec<String>
Return the telemetry log as a vector of strings.
Each entry is a formatted record of a dispatched command.
Sourcepub fn history(&self) -> Vec<String>
pub fn history(&self) -> Vec<String>
Return the full command history for agent introspection.
Agents can use this to review what commands have been processed and in what order, enabling replay and debugging.
Sourcepub fn session_count(&self) -> u64
pub fn session_count(&self) -> u64
Return the current session counter value.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CoreState
impl RefUnwindSafe for CoreState
impl Send for CoreState
impl Sync for CoreState
impl Unpin for CoreState
impl UnsafeUnpin for CoreState
impl UnwindSafe for CoreState
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