pub struct PortfolioConfig {
pub currencies: HashMap<String, Decimal>,
pub stocks: HashMap<String, i32>,
pub crypto: HashMap<String, Decimal>,
}Expand description
Main portfolio configuration structure
Fields§
§currencies: HashMap<String, Decimal>Currency holdings (e.g., EUR, USD)
stocks: HashMap<String, i32>Stock holdings (e.g., AAPL, GOOGL) - quantities as integers
crypto: HashMap<String, Decimal>Cryptocurrency holdings (e.g., bitcoin, ethereum, or contract/chain)
Implementations§
Source§impl PortfolioConfig
impl PortfolioConfig
Sourcepub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self>
Load portfolio configuration from a TOML file
Sourcepub fn from_toml_str(content: &str) -> Result<Self>
pub fn from_toml_str(content: &str) -> Result<Self>
Parse portfolio configuration from a TOML string (basic validation)
Sourcepub async fn from_str_validated(content: &str) -> Result<Self>
pub async fn from_str_validated(content: &str) -> Result<Self>
Parse portfolio configuration from a TOML string with full async validation
Sourcepub fn validate_basic(&self) -> Result<()>
pub fn validate_basic(&self) -> Result<()>
Basic validation for backwards compatibility
Sourcepub async fn validate(&self) -> Result<()>
pub async fn validate(&self) -> Result<()>
Validate the configuration using the validation pipeline
Sourcepub fn asset_count(&self) -> usize
pub fn asset_count(&self) -> usize
Get total number of assets in the portfolio
Sourcepub fn get_crypto_assets(&self) -> Vec<(CryptoAsset, Decimal)>
pub fn get_crypto_assets(&self) -> Vec<(CryptoAsset, Decimal)>
Get parsed crypto assets with their amounts
Trait Implementations§
Source§impl Clone for PortfolioConfig
impl Clone for PortfolioConfig
Source§fn clone(&self) -> PortfolioConfig
fn clone(&self) -> PortfolioConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PortfolioConfig
impl Debug for PortfolioConfig
Source§impl Default for PortfolioConfig
impl Default for PortfolioConfig
Source§fn default() -> PortfolioConfig
fn default() -> PortfolioConfig
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for PortfolioConfig
impl<'de> Deserialize<'de> for PortfolioConfig
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
Source§impl FromStr for PortfolioConfig
impl FromStr for PortfolioConfig
Auto Trait Implementations§
impl Freeze for PortfolioConfig
impl RefUnwindSafe for PortfolioConfig
impl Send for PortfolioConfig
impl Sync for PortfolioConfig
impl Unpin for PortfolioConfig
impl UnwindSafe for PortfolioConfig
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
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