pub struct DatabaseQueries;
Implementations§
Source§impl DatabaseQueries
impl DatabaseQueries
Sourcepub fn serialize_payload<T: Serialize>(
encoding: SerializationEncoding,
payload: &T,
) -> Result<Vec<u8>>
pub fn serialize_payload<T: Serialize>( encoding: SerializationEncoding, payload: &T, ) -> Result<Vec<u8>>
Serializes the given payload
using the specified encoding
to a byte vector.
§Errors
Returns an error if serialization to the chosen encoding fails.
Sourcepub fn deserialize_payload<T: DeserializeOwned>(
encoding: SerializationEncoding,
payload: &[u8],
) -> Result<T>
pub fn deserialize_payload<T: DeserializeOwned>( encoding: SerializationEncoding, payload: &[u8], ) -> Result<T>
Deserializes the given byte slice payload
into type T
using the specified encoding
.
§Errors
Returns an error if deserialization from the chosen encoding fails or converting to the target type fails.
Sourcepub async fn scan_keys(
con: &mut ConnectionManager,
pattern: String,
) -> Result<Vec<String>>
pub async fn scan_keys( con: &mut ConnectionManager, pattern: String, ) -> Result<Vec<String>>
Scans Redis for keys matching the given pattern
.
§Errors
Returns an error if the Redis scan operation fails.
Sourcepub async fn read(
con: &ConnectionManager,
trader_key: &str,
key: &str,
) -> Result<Vec<Bytes>>
pub async fn read( con: &ConnectionManager, trader_key: &str, key: &str, ) -> Result<Vec<Bytes>>
Reads raw byte payloads for key
under trader_key
from Redis.
§Errors
Returns an error if the underlying Redis read operation fails or if the collection is unsupported.
Sourcepub async fn load_all(
con: &ConnectionManager,
encoding: SerializationEncoding,
trader_key: &str,
) -> Result<CacheMap>
pub async fn load_all( con: &ConnectionManager, encoding: SerializationEncoding, trader_key: &str, ) -> Result<CacheMap>
Loads all cache data (currencies, instruments, synthetics, accounts, orders, positions) for trader_key
.
§Errors
Returns an error if loading any of the individual caches fails or combining data fails.
Sourcepub async fn load_currencies(
con: &ConnectionManager,
trader_key: &str,
encoding: SerializationEncoding,
) -> Result<HashMap<Ustr, Currency>>
pub async fn load_currencies( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<HashMap<Ustr, Currency>>
Loads all currencies for trader_key
using the specified encoding
.
§Errors
Returns an error if scanning keys or reading currency data fails.
Sourcepub async fn load_instruments(
con: &ConnectionManager,
trader_key: &str,
encoding: SerializationEncoding,
) -> Result<HashMap<InstrumentId, InstrumentAny>>
pub async fn load_instruments( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<HashMap<InstrumentId, InstrumentAny>>
Sourcepub async fn load_synthetics(
con: &ConnectionManager,
trader_key: &str,
encoding: SerializationEncoding,
) -> Result<HashMap<InstrumentId, SyntheticInstrument>>
pub async fn load_synthetics( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<HashMap<InstrumentId, SyntheticInstrument>>
Loads all synthetic instruments for trader_key
using the specified encoding
.
§Errors
Returns an error if scanning keys or reading synthetic instrument data fails.
Loads all synthetic instruments for trader_key
using the specified encoding
.
§Errors
Returns an error if scanning keys or reading synthetic instrument data fails.
Sourcepub async fn load_accounts(
con: &ConnectionManager,
trader_key: &str,
encoding: SerializationEncoding,
) -> Result<HashMap<AccountId, AccountAny>>
pub async fn load_accounts( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<HashMap<AccountId, AccountAny>>
Sourcepub async fn load_orders(
con: &ConnectionManager,
trader_key: &str,
encoding: SerializationEncoding,
) -> Result<HashMap<ClientOrderId, OrderAny>>
pub async fn load_orders( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<HashMap<ClientOrderId, OrderAny>>
Sourcepub async fn load_positions(
con: &ConnectionManager,
trader_key: &str,
encoding: SerializationEncoding,
) -> Result<HashMap<PositionId, Position>>
pub async fn load_positions( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<HashMap<PositionId, Position>>
Sourcepub async fn load_currency(
con: &ConnectionManager,
trader_key: &str,
code: &Ustr,
encoding: SerializationEncoding,
) -> Result<Option<Currency>>
pub async fn load_currency( con: &ConnectionManager, trader_key: &str, code: &Ustr, encoding: SerializationEncoding, ) -> Result<Option<Currency>>
Loads a single currency for trader_key
and code
using the specified encoding
.
§Errors
Returns an error if the underlying read or deserialization fails.
Sourcepub async fn load_instrument(
con: &ConnectionManager,
trader_key: &str,
instrument_id: &InstrumentId,
encoding: SerializationEncoding,
) -> Result<Option<InstrumentAny>>
pub async fn load_instrument( con: &ConnectionManager, trader_key: &str, instrument_id: &InstrumentId, encoding: SerializationEncoding, ) -> Result<Option<InstrumentAny>>
Loads a single instrument for trader_key
and instrument_id
using the specified encoding
.
§Errors
Returns an error if the underlying read or deserialization fails.
Sourcepub async fn load_synthetic(
con: &ConnectionManager,
trader_key: &str,
instrument_id: &InstrumentId,
encoding: SerializationEncoding,
) -> Result<Option<SyntheticInstrument>>
pub async fn load_synthetic( con: &ConnectionManager, trader_key: &str, instrument_id: &InstrumentId, encoding: SerializationEncoding, ) -> Result<Option<SyntheticInstrument>>
Loads a single synthetic instrument for trader_key
and instrument_id
using the specified encoding
.
§Errors
Returns an error if the underlying read or deserialization fails.
Sourcepub async fn load_account(
con: &ConnectionManager,
trader_key: &str,
account_id: &AccountId,
encoding: SerializationEncoding,
) -> Result<Option<AccountAny>>
pub async fn load_account( con: &ConnectionManager, trader_key: &str, account_id: &AccountId, encoding: SerializationEncoding, ) -> Result<Option<AccountAny>>
Loads a single account for trader_key
and account_id
using the specified encoding
.
§Errors
Returns an error if the underlying read or deserialization fails.
Sourcepub async fn load_order(
con: &ConnectionManager,
trader_key: &str,
client_order_id: &ClientOrderId,
encoding: SerializationEncoding,
) -> Result<Option<OrderAny>>
pub async fn load_order( con: &ConnectionManager, trader_key: &str, client_order_id: &ClientOrderId, encoding: SerializationEncoding, ) -> Result<Option<OrderAny>>
Loads a single order for trader_key
and client_order_id
using the specified encoding
.
§Errors
Returns an error if the underlying read or deserialization fails.
Sourcepub async fn load_position(
con: &ConnectionManager,
trader_key: &str,
position_id: &PositionId,
encoding: SerializationEncoding,
) -> Result<Option<Position>>
pub async fn load_position( con: &ConnectionManager, trader_key: &str, position_id: &PositionId, encoding: SerializationEncoding, ) -> Result<Option<Position>>
Loads a single position for trader_key
and position_id
using the specified encoding
.
§Errors
Returns an error if the underlying read or deserialization fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DatabaseQueries
impl RefUnwindSafe for DatabaseQueries
impl Send for DatabaseQueries
impl Sync for DatabaseQueries
impl Unpin for DatabaseQueries
impl UnwindSafe for DatabaseQueries
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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