pub struct UserState {
pub user: String,
pub orders: HashMap<String, Order>,
pub balances: HashMap<String, BalanceEntry>,
/* private fields */
}Expand description
User state tracking orders and balances
Fields§
§user: StringUser public key
orders: HashMap<String, Order>Open orders by order hash
balances: HashMap<String, BalanceEntry>Balances by market_pubkey:deposit_mint key
Implementations§
Source§impl UserState
impl UserState
Sourcepub fn apply_snapshot(&mut self, data: &UserEventData)
pub fn apply_snapshot(&mut self, data: &UserEventData)
Apply a snapshot (full user state)
Sourcepub fn apply_order_update(&mut self, data: &UserEventData)
pub fn apply_order_update(&mut self, data: &UserEventData)
Apply an order update
Sourcepub fn apply_balance_update(&mut self, data: &UserEventData)
pub fn apply_balance_update(&mut self, data: &UserEventData)
Apply a balance update
Sourcepub fn apply_event(&mut self, data: &UserEventData)
pub fn apply_event(&mut self, data: &UserEventData)
Apply any user event
Sourcepub fn open_orders(&self) -> Vec<&Order>
pub fn open_orders(&self) -> Vec<&Order>
Get all open orders
Sourcepub fn orders_for_market(&self, market_pubkey: &str) -> Vec<&Order>
pub fn orders_for_market(&self, market_pubkey: &str) -> Vec<&Order>
Get orders for a specific market
Sourcepub fn orders_for_orderbook(&self, orderbook_id: &str) -> Vec<&Order>
pub fn orders_for_orderbook(&self, orderbook_id: &str) -> Vec<&Order>
Get orders for a specific orderbook
Sourcepub fn get_balance(
&self,
market_pubkey: &str,
deposit_mint: &str,
) -> Option<&BalanceEntry>
pub fn get_balance( &self, market_pubkey: &str, deposit_mint: &str, ) -> Option<&BalanceEntry>
Get balance for a market/deposit_mint pair
Sourcepub fn all_balances(&self) -> Vec<&BalanceEntry>
pub fn all_balances(&self) -> Vec<&BalanceEntry>
Get all balances
Sourcepub fn idle_balance_for_outcome(
&self,
market_pubkey: &str,
deposit_mint: &str,
outcome_index: i32,
) -> Option<String>
pub fn idle_balance_for_outcome( &self, market_pubkey: &str, deposit_mint: &str, outcome_index: i32, ) -> Option<String>
Get total idle balance for a specific outcome as a string
Sourcepub fn on_book_balance_for_outcome(
&self,
market_pubkey: &str,
deposit_mint: &str,
outcome_index: i32,
) -> Option<String>
pub fn on_book_balance_for_outcome( &self, market_pubkey: &str, deposit_mint: &str, outcome_index: i32, ) -> Option<String>
Get total on-book balance for a specific outcome as a string
Sourcepub fn order_count(&self) -> usize
pub fn order_count(&self) -> usize
Number of open orders
Sourcepub fn has_snapshot(&self) -> bool
pub fn has_snapshot(&self) -> bool
Whether the user state has received its initial snapshot
Sourcepub fn last_timestamp(&self) -> Option<&str>
pub fn last_timestamp(&self) -> Option<&str>
Last update timestamp
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UserState
impl RefUnwindSafe for UserState
impl Send for UserState
impl Sync for UserState
impl Unpin for UserState
impl UnwindSafe for UserState
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more