pub struct Balance {
pub balances: HashMap<String, BalanceEntry>,
pub info: HashMap<String, Value>,
}Expand description
Balance structure containing all currency balances
Fields§
§balances: HashMap<String, BalanceEntry>Map of currency code to balance entry
info: HashMap<String, Value>Raw exchange info
Implementations§
Source§impl Balance
impl Balance
Sourcepub fn get(&self, currency: &str) -> Option<&BalanceEntry>
pub fn get(&self, currency: &str) -> Option<&BalanceEntry>
Get balance for a specific currency
Sourcepub fn get_mut(&mut self, currency: &str) -> Option<&mut BalanceEntry>
pub fn get_mut(&mut self, currency: &str) -> Option<&mut BalanceEntry>
Get mutable balance for a specific currency
Sourcepub fn set(&mut self, currency: String, entry: BalanceEntry)
pub fn set(&mut self, currency: String, entry: BalanceEntry)
Set balance for a currency
Sourcepub fn apply_delta(&mut self, currency: String, delta: Decimal)
pub fn apply_delta(&mut self, currency: String, delta: Decimal)
Apply delta to a currency balance
If currency doesn’t exist, creates new entry with delta as free balance
§Arguments
currency- Currency codedelta- Amount to add (can be negative)
Sourcepub fn update_balance(
&mut self,
currency: String,
free: Decimal,
locked: Decimal,
)
pub fn update_balance( &mut self, currency: String, free: Decimal, locked: Decimal, )
Update balance from complete data (for outboundAccountPosition)
§Arguments
currency- Currency codefree- Free balancelocked- Locked/used balance
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Balance
impl<'de> Deserialize<'de> for Balance
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Balance, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Balance, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Balance
impl Serialize for Balance
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for Balance
impl RefUnwindSafe for Balance
impl Send for Balance
impl Sync for Balance
impl Unpin for Balance
impl UnwindSafe for Balance
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