pub struct User {
pub id: String,
pub name: String,
pub broker: BrokerType,
pub token_env_var: String,
pub credentials: HashMap<String, String>,
pub accounts: Vec<Account>,
pub enabled: bool,
}Expand description
A user representing a connection to an exchange/broker.
Fields§
§id: StringUnique user identifier (auto-generated if not provided).
name: StringHuman-readable user name.
broker: BrokerTypeThe broker/exchange type.
token_env_var: StringEnvironment variable name for the API token.
credentials: HashMap<String, String>Additional API credentials (e.g., API secret for Binance).
accounts: Vec<Account>Trading accounts for this user.
enabled: boolWhether this user is enabled.
Implementations§
Source§impl User
impl User
Sourcepub fn new(broker: BrokerType, token_env_var: impl Into<String>) -> Self
pub fn new(broker: BrokerType, token_env_var: impl Into<String>) -> Self
Creates a new user for a broker.
Sourcepub fn with_credential(
self,
key: impl Into<String>,
env_var: impl Into<String>,
) -> Self
pub fn with_credential( self, key: impl Into<String>, env_var: impl Into<String>, ) -> Self
Adds a credential (e.g., API secret).
Sourcepub fn add_account(&mut self, account: Account)
pub fn add_account(&mut self, account: Account)
Adds an account to this user.
Sourcepub fn get_account(&self, id: &str) -> Option<&Account>
pub fn get_account(&self, id: &str) -> Option<&Account>
Returns an account by ID.
Sourcepub fn get_account_mut(&mut self, id: &str) -> Option<&mut Account>
pub fn get_account_mut(&mut self, id: &str) -> Option<&mut Account>
Returns a mutable account by ID.
Sourcepub fn active_accounts(&self) -> impl Iterator<Item = &Account>
pub fn active_accounts(&self) -> impl Iterator<Item = &Account>
Returns all enabled accounts.
Sourcepub fn all_tickers(&self) -> Vec<String>
pub fn all_tickers(&self) -> Vec<String>
Returns all tickers across all accounts.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for User
impl<'de> Deserialize<'de> for User
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Forget for User
impl Freeze for User
impl Move for User
impl RefUnwindSafe for User
impl Send for User
impl Sync for User
impl Unpin for User
impl UnsafeUnpin for User
impl UnwindSafe for User
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