finql_data/
asset_handler.rs

1use async_trait::async_trait;
2
3use super::DataError;
4use crate::asset::Asset;
5use crate::currency::Currency;
6
7/// Handler for globally available data of transactions and related data
8#[async_trait]
9pub trait AssetHandler {
10    // insert, get, update and delete for assets
11    async fn insert_asset(&self, asset: &Asset) -> Result<usize, DataError>;
12    async fn insert_asset_if_new(
13        &self,
14        asset: &Asset,
15        rename_asset: bool,
16    ) -> Result<usize, DataError>; 
17    
18    async fn get_asset_id(&self, asset: &Asset) -> Option<usize>;
19    async fn get_asset_by_id(&self, id: usize) -> Result<Asset, DataError>;
20    async fn get_asset_by_isin(&self, id: &str) -> Result<Asset, DataError>;
21    /// Return a list of all assets ordered by name 
22    async fn get_all_assets(&self) -> Result<Vec<Asset>, DataError>;
23    async fn update_asset(&self, asset: &Asset) -> Result<(), DataError>;
24    async fn delete_asset(&self, id: usize) -> Result<(), DataError>;
25    /// We assume here that a currency is an Asset with a three letter name and no ISIN nor WKN
26    async fn get_all_currencies(&self) -> Result<Vec<Currency>, DataError>;
27}