Skip to main content

CoreState

Struct CoreState 

Source
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,
        context: serde_json::Value::Null,
    },
};
let result = state.dispatch(command);
assert_eq!(result.message, "State synchronized");

Implementations§

Source§

impl CoreState

Source

pub fn new() -> Self

Create a new core state with zeroed counters and empty logs.

Source

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.

Source

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.

Source

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.

Source

pub fn session_count(&self) -> u64

Return the current session counter value.

Trait Implementations§

Source§

impl Debug for CoreState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CoreState

Source§

fn default() -> CoreState

Returns the “default value” for a type. Read more

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, 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.