Trait AuthRepository

Source
pub trait AuthRepository: ProductRepository {
    type PortfolioOptions: Default + Serialize + DeserializeOwned + Send;

    // Required methods
    fn create<K: Borrow<ProductId>, V: Borrow<f64>, P: Borrow<(K, V)>>(
        &self,
        bidder_id: BidderId,
        auth_id: Option<AuthId>,
        portfolio: impl Iterator<Item = P> + Send,
        data: AuthData,
        timestamp: OffsetDateTime,
        portfolio_options: Self::PortfolioOptions,
    ) -> impl Future<Output = Result<Result<AuthRecord, AuthFailure>, Self::Error>> + Send;
    fn read(
        &self,
        bidder_id: BidderId,
        auth_id: AuthId,
        as_of: OffsetDateTime,
        portfolio_options: Self::PortfolioOptions,
    ) -> impl Future<Output = Result<Result<AuthRecord, AuthFailure>, Self::Error>> + Send;
    fn update(
        &self,
        bidder_id: BidderId,
        auth_id: AuthId,
        data: AuthData,
        timestamp: OffsetDateTime,
        portfolio_options: Self::PortfolioOptions,
    ) -> impl Future<Output = Result<Result<AuthRecord, AuthFailure>, Self::Error>> + Send;
    fn delete(
        &self,
        bidder_id: BidderId,
        auth_id: AuthId,
        timestamp: OffsetDateTime,
        portfolio_options: Self::PortfolioOptions,
    ) -> impl Future<Output = Result<Result<AuthRecord, AuthFailure>, Self::Error>> + Send;
    fn query_by_product(
        &self,
        bidder_id: BidderId,
        product_id: ProductId,
        as_of: OffsetDateTime,
    ) -> impl Future<Output = Result<Vec<AuthRecord>, Self::Error>> + Send;
    fn get_history(
        &self,
        bidder_id: BidderId,
        auth_id: AuthId,
        query: DateTimeRangeQuery,
        limit: usize,
    ) -> impl Future<Output = Result<Result<DateTimeRangeResponse<AuthHistoryRecord>, AuthFailure>, Self::Error>> + Send;
    fn get_outcomes(
        &self,
        bidder_id: BidderId,
        auth_id: AuthId,
        query: DateTimeRangeQuery,
        limit: usize,
    ) -> impl Future<Output = Result<Result<DateTimeRangeResponse<AuctionOutcome<()>>, AuthFailure>, Self::Error>> + Send;
}
Expand description

Repository for managing authorization records and related operations.

In the flow trading system, an auth (short for authorization) represents:

  1. A portfolio, which is a weighted bundle of products.
  2. Constraints on how this portfolio can be traded.

Portfolios define what combination of products an auth trades, with weights determining the relative proportions. Positive weights indicate buying the product, negative weights indicate selling.

Auth constraints include:

  • Rate constraints (min_rate, max_rate) which limit how fast a portfolio can be traded
  • Trade constraints (min_trade, max_trade) which limit the total accumulated trade

This trait extends ProductRepository to provide functionality for creating, reading, updating, and deleting authorization records, as well as querying authorizations by product and retrieving historical records and auction outcomes.

Required Associated Types§

Source

type PortfolioOptions: Default + Serialize + DeserializeOwned + Send

Implementations may elect to display (or not) the porfolio in various ways. At a minimum, this should be a bool on whether or not to include the portfolio in a response; in a forward market application with increasingly granular products, this might be an option to display the original portfolio or the “effective” portfolio.

Required Methods§

Source

fn create<K: Borrow<ProductId>, V: Borrow<f64>, P: Borrow<(K, V)>>( &self, bidder_id: BidderId, auth_id: Option<AuthId>, portfolio: impl Iterator<Item = P> + Send, data: AuthData, timestamp: OffsetDateTime, portfolio_options: Self::PortfolioOptions, ) -> impl Future<Output = Result<Result<AuthRecord, AuthFailure>, Self::Error>> + Send

Create a new authorization associated to the given bidder.

If auth_id is None, assigns a system-generated ID.

Source

fn read( &self, bidder_id: BidderId, auth_id: AuthId, as_of: OffsetDateTime, portfolio_options: Self::PortfolioOptions, ) -> impl Future<Output = Result<Result<AuthRecord, AuthFailure>, Self::Error>> + Send

Retrieves the authorization record for the specified bidder and auth ID as of the given timestamp.

Returns the authorization record if successful, or an AuthFailure if the auth does not exist or the bidder lacks access permission.

Source

fn update( &self, bidder_id: BidderId, auth_id: AuthId, data: AuthData, timestamp: OffsetDateTime, portfolio_options: Self::PortfolioOptions, ) -> impl Future<Output = Result<Result<AuthRecord, AuthFailure>, Self::Error>> + Send

Updates the data associated with an existing authorization.

Returns the updated authorization record if successful, or an AuthFailure if the auth does not exist or the bidder lacks update permission.

Source

fn delete( &self, bidder_id: BidderId, auth_id: AuthId, timestamp: OffsetDateTime, portfolio_options: Self::PortfolioOptions, ) -> impl Future<Output = Result<Result<AuthRecord, AuthFailure>, Self::Error>> + Send

Marks the authorization as deleted. This is should be a logical delete rather than a physical removal from the repository.

Returns the deleted authorization record if successful, or an AuthFailure if the auth does not exist or the bidder lacks delete permission.

Source

fn query_by_product( &self, bidder_id: BidderId, product_id: ProductId, as_of: OffsetDateTime, ) -> impl Future<Output = Result<Vec<AuthRecord>, Self::Error>> + Send

Retrieves all active authorizations that involve the specified product as of the given timestamp for the specified bidder.

Returns a vector of matching authorization records.

Source

fn get_history( &self, bidder_id: BidderId, auth_id: AuthId, query: DateTimeRangeQuery, limit: usize, ) -> impl Future<Output = Result<Result<DateTimeRangeResponse<AuthHistoryRecord>, AuthFailure>, Self::Error>> + Send

Retrieves the historical records for a specific authorization within the given time range.

The limit parameter restricts the maximum number of records returned. Returns a paginated response of auth history records if successful, or an AuthFailure if the auth does not exist or the bidder lacks access permission.

Source

fn get_outcomes( &self, bidder_id: BidderId, auth_id: AuthId, query: DateTimeRangeQuery, limit: usize, ) -> impl Future<Output = Result<Result<DateTimeRangeResponse<AuctionOutcome<()>>, AuthFailure>, Self::Error>> + Send

Retrieves the auction outcomes associated with a specific authorization within the given time range.

The limit parameter restricts the maximum number of outcomes returned. Returns a paginated response of auction outcomes if successful, or an AuthFailure if the auth does not exist or the bidder lacks access permission.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§