Struct DatabaseQueries

Source
pub struct DatabaseQueries;

Implementations§

Source§

impl DatabaseQueries

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn load_instruments( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<HashMap<InstrumentId, InstrumentAny>>

Loads all instruments for trader_key using the specified encoding.

§Errors

Returns an error if scanning keys or reading instrument data fails. Loads all instruments for trader_key using the specified encoding.

§Errors

Returns an error if scanning keys or reading instrument data fails.

Source

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.

Source

pub async fn load_accounts( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<HashMap<AccountId, AccountAny>>

Loads all accounts for trader_key using the specified encoding.

§Errors

Returns an error if scanning keys or reading account data fails. Loads all accounts for trader_key using the specified encoding.

§Errors

Returns an error if scanning keys or reading account data fails.

Source

pub async fn load_orders( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<HashMap<ClientOrderId, OrderAny>>

Loads all orders for trader_key using the specified encoding.

§Errors

Returns an error if scanning keys or reading order data fails. Loads all orders for trader_key using the specified encoding.

§Errors

Returns an error if scanning keys or reading order data fails.

Source

pub async fn load_positions( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<HashMap<PositionId, Position>>

Loads all positions for trader_key using the specified encoding.

§Errors

Returns an error if scanning keys or reading position data fails. Loads all positions for trader_key using the specified encoding.

§Errors

Returns an error if scanning keys or reading position data fails.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Debug for DatabaseQueries

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Ungil for T
where T: Send,