pub struct PiecewiseLinear {
pub steps: Vec<(u64, Uint128)>,
}
Expand description
This is a generalization of SaturatingLinear, steps must be arranged with increasing time (u64). Any point before first step gets the first value, after last step the last value. Otherwise, it is a linear interpolation between the two closest points. Vec of length 1 -> Constant Vec of length 2 -> SaturatingLinear
Fields§
§steps: Vec<(u64, Uint128)>
Implementations§
Source§impl PiecewiseLinear
impl PiecewiseLinear
Sourcepub fn validate(&self) -> Result<(), CurveError>
pub fn validate(&self) -> Result<(), CurveError>
general sanity checks on input values to ensure this is valid. these checks should be included by the other validate_* functions
Sourcepub fn validate_monotonic_increasing(&self) -> Result<(), CurveError>
pub fn validate_monotonic_increasing(&self) -> Result<(), CurveError>
returns an error if there is ever x2 > x1 such that value(x2) < value(x1)
Sourcepub fn validate_monotonic_decreasing(&self) -> Result<(), CurveError>
pub fn validate_monotonic_decreasing(&self) -> Result<(), CurveError>
returns an error if there is ever x2 > x1 such that value(x1) < value(x2)
Trait Implementations§
Source§impl Clone for PiecewiseLinear
impl Clone for PiecewiseLinear
Source§fn clone(&self) -> PiecewiseLinear
fn clone(&self) -> PiecewiseLinear
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PiecewiseLinear
impl Debug for PiecewiseLinear
Source§impl<'de> Deserialize<'de> for PiecewiseLinear
impl<'de> Deserialize<'de> for PiecewiseLinear
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for PiecewiseLinear
impl JsonSchema for PiecewiseLinear
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moreSource§impl PartialEq for PiecewiseLinear
impl PartialEq for PiecewiseLinear
Source§impl Serialize for PiecewiseLinear
impl Serialize for PiecewiseLinear
impl StructuralPartialEq for PiecewiseLinear
Auto Trait Implementations§
impl Freeze for PiecewiseLinear
impl RefUnwindSafe for PiecewiseLinear
impl Send for PiecewiseLinear
impl Sync for PiecewiseLinear
impl Unpin for PiecewiseLinear
impl UnwindSafe for PiecewiseLinear
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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