pub enum DurationOfPart {
Auto,
LimitDuration {
duration: u32,
},
}Expand description
Duration constraint for each individual TWAP part.
DurationOfPart::Autoencodesspan = 0on-chain, meaning each part is valid for the entirepart_durationwindow.DurationOfPart::LimitDurationencodesspan = duration, restricting each part to a shorter window within the overall interval.
Variants§
Auto
Each part is valid for the full part_duration window (default).
LimitDuration
Each part is valid only for duration seconds within the window.
Implementations§
Source§impl DurationOfPart
impl DurationOfPart
Sourcepub const fn duration(self) -> Option<u32>
pub const fn duration(self) -> Option<u32>
Return the limit duration in seconds, or None for Auto.
Sourcepub const fn is_auto(self) -> bool
pub const fn is_auto(self) -> bool
Returns true if the part spans the full part_duration window.
Sourcepub const fn limit(duration: u32) -> Self
pub const fn limit(duration: u32) -> Self
Construct a LimitDuration variant.
use cow_composable::DurationOfPart;
let d = DurationOfPart::limit(1_800);
assert!(!d.is_auto());
assert_eq!(d.duration(), Some(1_800));Sourcepub const fn is_limit_duration(self) -> bool
pub const fn is_limit_duration(self) -> bool
Returns true if this is a LimitDuration variant.
use cow_composable::DurationOfPart;
assert!(DurationOfPart::limit(600).is_limit_duration());
assert!(!DurationOfPart::Auto.is_limit_duration());Trait Implementations§
Source§impl Clone for DurationOfPart
impl Clone for DurationOfPart
Source§fn clone(&self) -> DurationOfPart
fn clone(&self) -> DurationOfPart
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 DurationOfPart
impl Debug for DurationOfPart
Source§impl Default for DurationOfPart
impl Default for DurationOfPart
Source§fn default() -> DurationOfPart
fn default() -> DurationOfPart
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for DurationOfPart
impl<'de> Deserialize<'de> for DurationOfPart
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 Display for DurationOfPart
impl Display for DurationOfPart
Source§impl From<Option<u32>> for DurationOfPart
impl From<Option<u32>> for DurationOfPart
Source§fn from(d: Option<u32>) -> Self
fn from(d: Option<u32>) -> Self
Convert an optional duration to a DurationOfPart.
Some(d) maps to DurationOfPart::LimitDuration;
None maps to DurationOfPart::Auto.
Source§impl PartialEq for DurationOfPart
impl PartialEq for DurationOfPart
Source§impl Serialize for DurationOfPart
impl Serialize for DurationOfPart
impl Copy for DurationOfPart
impl Eq for DurationOfPart
impl StructuralPartialEq for DurationOfPart
Auto Trait Implementations§
impl Freeze for DurationOfPart
impl RefUnwindSafe for DurationOfPart
impl Send for DurationOfPart
impl Sync for DurationOfPart
impl Unpin for DurationOfPart
impl UnsafeUnpin for DurationOfPart
impl UnwindSafe for DurationOfPart
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.