Skip to main content

StateBridge

Struct StateBridge 

Source
pub struct StateBridge { /* private fields */ }
Expand description

State bridge for game state inspection

Provides unified access to game state whether using WasmRuntime (zero-copy) or BrowserController (serialized RPC).

Implementations§

Source§

impl StateBridge

Source

pub fn direct(memory_view: MemoryView) -> Self

Create bridge with direct memory access (for WasmRuntime)

Source

pub fn rpc(session_id: impl Into<String>) -> Self

Create bridge with RPC connection (for BrowserController)

Source

pub const fn is_direct(&self) -> bool

Check if using direct memory access

Source

pub const fn memory_view(&self) -> Option<&MemoryView>

Get the memory view if using direct mode

Source

pub fn query_entity(&self, entity_id: EntityId) -> ProbarResult<EntitySnapshot>

Query entity by ID

§Errors

Returns error if entity not found

Source

pub fn snapshot(&mut self, frame: u64) -> ProbarResult<GameStateSnapshot>

Get current game state snapshot

§Errors

Returns error if state cannot be captured

Source

pub fn record_delta(&mut self, delta: StateDelta)

Record a delta from current state

Source

pub fn deltas(&self) -> &[StateDelta]

Get delta history

Source

pub fn clear_deltas(&mut self)

Clear delta history

Source

pub fn compute_phash(image_data: &[u8]) -> u64

Compute perceptual hash for image

Per Shamir [19]: pHash is more robust than pixel comparison

Source

pub fn visual_compare(expected: &[u8], actual: &[u8]) -> VisualDiff

Compare two images using perceptual hash

Trait Implementations§

Source§

impl Debug for StateBridge

Source§

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

Formats the value using the given formatter. 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> 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.