cairo_lang_sierra_gas::compute_costs

Trait SpecificCostContextTrait

source
pub trait SpecificCostContextTrait<CostType: CostTypeTrait> {
    // Required methods
    fn to_cost_map(cost: CostType) -> OrderedHashMap<CostTokenType, i64>;
    fn to_full_cost_map(cost: CostType) -> OrderedHashMap<CostTokenType, i64>;
    fn get_gas_withdrawal(
        &self,
        idx: &StatementIdx,
        branch_cost: &BranchCost,
        wallet_value: &CostType,
        future_wallet_value: CostType,
    ) -> Result<CostType, CostError>;
    fn get_branch_requirement(
        &self,
        wallet_at_fn: &dyn Fn(&StatementIdx) -> WalletInfo<CostType>,
        idx: &StatementIdx,
        branch_info: &BranchInfo,
        branch_cost: &BranchCost,
    ) -> WalletInfo<CostType>;
}

Required Methods§

source

fn to_cost_map(cost: CostType) -> OrderedHashMap<CostTokenType, i64>

Converts a CostType to a OrderedHashMap from CostTokenType to i64.

source

fn to_full_cost_map(cost: CostType) -> OrderedHashMap<CostTokenType, i64>

Converts a CostType to a OrderedHashMap from CostTokenType to i64. All relevant CostTokenType are included (even if their value is 0).

source

fn get_gas_withdrawal( &self, idx: &StatementIdx, branch_cost: &BranchCost, wallet_value: &CostType, future_wallet_value: CostType, ) -> Result<CostType, CostError>

Computes the value that should be withdrawn and added to the wallet.

source

fn get_branch_requirement( &self, wallet_at_fn: &dyn Fn(&StatementIdx) -> WalletInfo<CostType>, idx: &StatementIdx, branch_info: &BranchInfo, branch_cost: &BranchCost, ) -> WalletInfo<CostType>

Returns the required value for the wallet for a single branch.

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§