pub struct PostgresDB {
pub pool: Pool<Postgres>,
}Expand description
Struct to handle connections to postgres databases
Fields§
§pool: Pool<Postgres>pool is made public to allow extending this struct outside of the library
Implementations§
Trait Implementations§
Source§impl AssetHandler for PostgresDB
Handler for globally available Asset data
impl AssetHandler for PostgresDB
Handler for globally available Asset data
Source§fn get_asset_list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AssetSelector>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_asset_list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AssetSelector>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return AssetSelector for all assets
fn insert_asset<'life0, 'life1, 'async_trait>(
&'life0 self,
asset: &'life1 Asset,
) -> Pin<Box<dyn Future<Output = Result<i32, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_asset_id<'life0, 'life1, 'async_trait>(
&'life0 self,
asset: &'life1 Asset,
) -> Pin<Box<dyn Future<Output = Option<i32>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_asset_by_id<'life0, 'async_trait>(
&'life0 self,
id: i32,
) -> Pin<Box<dyn Future<Output = Result<Asset, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_asset_by_isin<'life0, 'life1, 'async_trait>(
&'life0 self,
isin: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Asset, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_all_assets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Asset>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_all_assets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Asset>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return a list of all assets ordered by name
fn update_asset<'life0, 'life1, 'async_trait>(
&'life0 self,
asset: &'life1 Asset,
) -> Pin<Box<dyn Future<Output = Result<(), DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_asset<'life0, 'async_trait>(
&'life0 self,
id: i32,
) -> Pin<Box<dyn Future<Output = Result<(), DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_all_currencies<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Currency>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn get_currency_list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AssetSelector>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_currency_list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AssetSelector>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a list of currencies as list of AssetSelectors
Source§fn get_or_new_currency<'life0, 'async_trait>(
&'life0 self,
iso_code: CurrencyISOCode,
) -> Pin<Box<dyn Future<Output = Result<Currency, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_or_new_currency<'life0, 'async_trait>(
&'life0 self,
iso_code: CurrencyISOCode,
) -> Pin<Box<dyn Future<Output = Result<Currency, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Either read currency from database or create new currency and store it in database with default rounding digits
Source§fn get_or_new_currency_with_digits<'life0, 'async_trait>(
&'life0 self,
iso_code: CurrencyISOCode,
rounding_digits: i32,
) -> Pin<Box<dyn Future<Output = Result<Currency, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_or_new_currency_with_digits<'life0, 'async_trait>(
&'life0 self,
iso_code: CurrencyISOCode,
rounding_digits: i32,
) -> Pin<Box<dyn Future<Output = Result<Currency, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Either read currency from database or create new currency and store it in database.
If currency exists already, ignore rounding errors.
Source§impl ObjectHandler for PostgresDB
Handler for globally available Asset data
impl ObjectHandler for PostgresDB
Handler for globally available Asset data
fn store_object<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, id: &'life1 str, _object_type: &'life2 str, object: &'life3 T, ) -> Pin<Box<dyn Future<Output = Result<(), DataError>> + Send + 'async_trait>>
fn get_object<'life0, 'life1, 'async_trait, T>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<T, DataError>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl QuoteHandler for PostgresDB
PostgreSQL implementation of quote handler
impl QuoteHandler for PostgresDB
PostgreSQL implementation of quote handler
fn into_arc_dispatch(self: Arc<Self>) -> Arc<dyn AssetHandler + Send + Sync>
fn insert_ticker<'life0, 'life1, 'async_trait>(
&'life0 self,
ticker: &'life1 Ticker,
) -> Pin<Box<dyn Future<Output = Result<i32, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_ticker_id<'life0, 'life1, 'async_trait>(
&'life0 self,
ticker: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<i32>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn insert_if_new_ticker<'life0, 'life1, 'async_trait>(
&'life0 self,
ticker: &'life1 Ticker,
) -> Pin<Box<dyn Future<Output = Result<i32, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_ticker_by_id<'life0, 'async_trait>(
&'life0 self,
id: i32,
) -> Pin<Box<dyn Future<Output = Result<Ticker, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_all_ticker<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Ticker>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_all_ticker_for_source<'life0, 'life1, 'async_trait>(
&'life0 self,
source: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Ticker>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_all_ticker_for_asset<'life0, 'async_trait>(
&'life0 self,
asset_id: i32,
) -> Pin<Box<dyn Future<Output = Result<Vec<Ticker>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_all_ticker_for_asset<'life0, 'async_trait>(
&'life0 self,
asset_id: i32,
) -> Pin<Box<dyn Future<Output = Result<Vec<Ticker>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get all ticker that belong to a given asset specified by its asset ID
fn update_ticker<'life0, 'life1, 'async_trait>(
&'life0 self,
ticker: &'life1 Ticker,
) -> Pin<Box<dyn Future<Output = Result<(), DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_ticker<'life0, 'async_trait>(
&'life0 self,
id: i32,
) -> Pin<Box<dyn Future<Output = Result<(), DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn insert_quote<'life0, 'life1, 'async_trait>(
&'life0 self,
quote: &'life1 Quote,
) -> Pin<Box<dyn Future<Output = Result<i32, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn insert_quote<'life0, 'life1, 'async_trait>(
&'life0 self,
quote: &'life1 Quote,
) -> Pin<Box<dyn Future<Output = Result<i32, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Insert, get, update and delete for market data sources
Source§fn get_last_fx_quote_before<'life0, 'life1, 'async_trait>(
&'life0 self,
curr: &'life1 CurrencyISOCode,
time: DateTime<Local>,
) -> Pin<Box<dyn Future<Output = Result<(Quote, Currency), DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_last_fx_quote_before<'life0, 'life1, 'async_trait>(
&'life0 self,
curr: &'life1 CurrencyISOCode,
time: DateTime<Local>,
) -> Pin<Box<dyn Future<Output = Result<(Quote, Currency), DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get the last quote in database for a specific currency iso code on or before the given time
Source§fn get_last_quote_before_by_id<'life0, 'async_trait>(
&'life0 self,
asset_id: i32,
time: DateTime<Local>,
) -> Pin<Box<dyn Future<Output = Result<(Quote, Currency), DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_last_quote_before_by_id<'life0, 'async_trait>(
&'life0 self,
asset_id: i32,
time: DateTime<Local>,
) -> Pin<Box<dyn Future<Output = Result<(Quote, Currency), DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the last quote in database for a specific asset id on or before the given time
Source§fn get_quotes_in_range_by_id<'life0, 'async_trait>(
&'life0 self,
asset_id: i32,
start: DateTime<Local>,
end: DateTime<Local>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(Quote, i32)>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_quotes_in_range_by_id<'life0, 'async_trait>(
&'life0 self,
asset_id: i32,
start: DateTime<Local>,
end: DateTime<Local>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(Quote, i32)>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get all quotes within a time range for a specific asset id
fn get_all_quotes_for_ticker<'life0, 'async_trait>(
&'life0 self,
ticker_id: i32,
) -> Pin<Box<dyn Future<Output = Result<Vec<Quote>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_quote<'life0, 'life1, 'async_trait>(
&'life0 self,
quote: &'life1 Quote,
) -> Pin<Box<dyn Future<Output = Result<(), DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_quote<'life0, 'async_trait>(
&'life0 self,
id: i32,
) -> Pin<Box<dyn Future<Output = Result<(), DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn remove_duplicates<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl TransactionHandler for PostgresDB
Handler for globally available data
impl TransactionHandler for PostgresDB
Handler for globally available data
fn insert_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
transaction: &'life1 Transaction,
) -> Pin<Box<dyn Future<Output = Result<i32, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_transaction_by_id<'life0, 'async_trait>(
&'life0 self,
id: i32,
) -> Pin<Box<dyn Future<Output = Result<Transaction, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_all_transactions<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>, DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
transaction: &'life1 Transaction,
) -> Pin<Box<dyn Future<Output = Result<(), DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_transaction<'life0, 'async_trait>(
&'life0 self,
id: i32,
) -> Pin<Box<dyn Future<Output = Result<(), DataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl Freeze for PostgresDB
impl !RefUnwindSafe for PostgresDB
impl Send for PostgresDB
impl Sync for PostgresDB
impl Unpin for PostgresDB
impl UnsafeUnpin for PostgresDB
impl !UnwindSafe for PostgresDB
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> 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