pub trait SorobanFixedPoint: Sized {
// Required methods
fn fixed_mul_floor(&self, env: &Env, y: &Self, denominator: &Self) -> Self;
fn fixed_mul_ceil(&self, env: &Env, y: &Self, denominator: &Self) -> Self;
fn fixed_div_floor(&self, env: &Env, y: &Self, denominator: &Self) -> Self;
fn fixed_div_ceil(&self, env: &Env, y: &Self, denominator: &Self) -> Self;
}
Expand description
Soroban fixed point trait for computing fixed point calculations with Soroban host objects.
Soroban host functions by default are non-recoverable. This means an arithmetic overflow or divide by zero will result in a host panic instead of returning an error. For consistency, this trait will also panic in the same manner.
Required Methods§
Sourcefn fixed_mul_floor(&self, env: &Env, y: &Self, denominator: &Self) -> Self
fn fixed_mul_floor(&self, env: &Env, y: &Self, denominator: &Self) -> Self
Safely calculates floor(x * y / denominator).
§Panics
This method will panic if the denominator is 0, a phantom overflow occurs, or the result does not fit in Self.
Sourcefn fixed_mul_ceil(&self, env: &Env, y: &Self, denominator: &Self) -> Self
fn fixed_mul_ceil(&self, env: &Env, y: &Self, denominator: &Self) -> Self
Safely calculates ceil(x * y / denominator).
§Panics
This method will panic if the denominator is 0, a phantom overflow occurs, or the result does not fit in Self.
Sourcefn fixed_div_floor(&self, env: &Env, y: &Self, denominator: &Self) -> Self
fn fixed_div_floor(&self, env: &Env, y: &Self, denominator: &Self) -> Self
Safely calculates floor(x * denominator / y).
§Panics
This method will panic if the denominator is 0, a phantom overflow occurs, or the result does not fit in Self.
Sourcefn fixed_div_ceil(&self, env: &Env, y: &Self, denominator: &Self) -> Self
fn fixed_div_ceil(&self, env: &Env, y: &Self, denominator: &Self) -> Self
Safely calculates ceil(x * denominator / y).
§Panics
This method will panic if the denominator is 0, a phantom overflow occurs, or the result does not fit in Self.
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.