Skip to main content

ObserverData

Struct ObserverData 

Source
#[repr(C, packed(1))]
pub struct ObserverData { pub version: u32, pub refresh_rate: u32, pub game: ObserverGame, pub players: [PlayerInfo; 28], pub shop_count: u32, pub shops: [ShopInfo; 999], }
Expand description

Top-level layout of the Warcraft III Stats Observer shared memory map.

This is the type ObserverHandle dereferences to. Because the underlying memory is updated by Warcraft III, all numeric fields can change between reads. The struct is #[repr(C, packed)], so borrow individual fields by copying them with { ... }:

println!("version: {}", { observer.version });

Fields§

§version: u32

Not quite sure what this version number is supposed to represent.

§refresh_rate: u32

Current refresh rate of the API in milliseconds. A value of 0 disables updates.

§game: ObserverGame

Game-wide state (clock, map name, in-game flag, …).

§players: [PlayerInfo; 28]

Per-player state. Only the first ObserverGame::active_player_count entries are meaningful.

§shop_count: u32

Number of valid entries in Self::shops.

§shops: [ShopInfo; 999]

Per-shop state. Only the first Self::shop_count entries are meaningful.

Implementations§

Source§

impl ObserverData

Source

pub fn disable(&mut self)

Disables observer updates by writing a refresh rate of 0.

Source

pub fn set_refresh_rate(&mut self, duration: Duration)

Sets the observer’s refresh rate. Sub-millisecond precision is truncated. A duration of zero disables updates.

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.