Skip to main content

DatabaseQueries

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.

Timestamp-like keys in general metadata also convert numeric and ISO strings to integers.

§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_bulk( con: &ConnectionManager, keys: &[String], ) -> Result<Vec<Option<Bytes>>>

Bulk reads multiple keys from Redis using MGET for efficiency.

§Errors

Returns an error if the underlying Redis MGET operation fails.

Source

pub async fn read_bulk_batched( con: &ConnectionManager, keys: &[String], batch_size: usize, ) -> Result<Vec<Option<Bytes>>>

Bulk reads multiple keys from Redis using MGET, batched into chunks.

Keys are batched into chunks of batch_size to avoid exceeding Redis request size limits on some providers.

§Errors

Returns an error if batch_size is zero or if the underlying Redis MGET 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 the supported cache records for trader_key.

Greeks and yield curves are empty because Redis does not persist them.

§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<AHashMap<Ustr, Currency>>

Loads all currencies for trader_key using the specified encoding.

§Errors

Returns an error if scanning keys or reading currency data fails, or if a stored record describes an invalid currency.

Source

pub async fn load_instruments( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<AHashMap<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_instrument_closes( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<AHashMap<InstrumentId, InstrumentClose>>

Loads all instrument closes for trader_key.

Missing or invalid close data fails the load so recovery cannot silently omit a close.

§Errors

Returns an error if scanning, reading, parsing, or deserializing instrument closes fails.

Source

pub async fn load_synthetics( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<AHashMap<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.

Source

pub async fn load_accounts( con: &ConnectionManager, trader_key: &str, encoding: SerializationEncoding, ) -> Result<AHashMap<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<AHashMap<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<AHashMap<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_index_order_position( con: &ConnectionManager, trader_key: &str, ) -> Result<AHashMap<ClientOrderId, PositionId>>

Loads the order ID to position ID index for trader_key.

§Errors

Returns an error if reading or parsing the index fails.

Source

pub async fn load_index_order_client( con: &ConnectionManager, trader_key: &str, ) -> Result<AHashMap<ClientOrderId, ClientId>>

Loads the order ID to execution client ID index for trader_key.

§Errors

Returns an error if reading or parsing the index fails.

Source

pub async fn load_custom_data( con: &ConnectionManager, trader_key: &str, data_type: &DataType, ) -> Result<Vec<CustomData>>

Loads all custom data for trader_key matching the given data_type.

Keys are stored as custom:<ts_init_020>:<uuid>; value is full CustomData JSON. Scans all custom keys, deserializes, filters by type_name (full or short), metadata, and identifier to match SQL semantics, then sorts by ts_init ascending.

§Errors

Returns an error if scanning, bulk read, or deserialization 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§

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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<T> Ungil for T
where T: Send,

§

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