pub enum PollResult {
Success {
order: Option<UnsignedOrder>,
signature: Option<String>,
},
TryNextBlock,
TryOnBlock {
block_number: u64,
},
TryAtEpoch {
epoch: u64,
},
UnexpectedError {
message: String,
},
DontTryAgain {
reason: String,
},
}Expand description
Result returned when polling a conditional order for tradability.
On Success, contains the on-chain order struct and the pre-signature bytes
ready for submission to the orderbook.
Variants§
Success
The order is valid and can be submitted now.
When returned by a full signing poll, order and signature are set to
the resolved GPv2Order.Data struct and the ABI-encoded signature.
When returned by an offline validity check (e.g. TwapOrder::poll_validate),
both fields are None.
Fields
order: Option<UnsignedOrder>The resolved order ready for submission (None for offline checks).
TryNextBlock
Retry on the next block.
TryOnBlock
Retry once the given block number is reached.
TryAtEpoch
Retry once the given Unix timestamp is reached.
UnexpectedError
An unexpected error occurred.
DontTryAgain
This order should never be polled again.
Implementations§
Source§impl PollResult
impl PollResult
Sourcepub const fn is_success(&self) -> bool
pub const fn is_success(&self) -> bool
Sourcepub const fn is_retryable(&self) -> bool
pub const fn is_retryable(&self) -> bool
Returns true if polling should be retried in a future block or epoch.
§Returns
true for TryNextBlock, TryOnBlock,
or TryAtEpoch; false otherwise.
Sourcepub const fn is_terminal(&self) -> bool
pub const fn is_terminal(&self) -> bool
Returns true if this order should never be polled again.
§Returns
true for the DontTryAgain variant, false otherwise.
Sourcepub const fn is_try_next_block(&self) -> bool
pub const fn is_try_next_block(&self) -> bool
Returns true if polling should retry on the very next block.
§Returns
true for the TryNextBlock variant, false otherwise.
Sourcepub const fn is_try_on_block(&self) -> bool
pub const fn is_try_on_block(&self) -> bool
Returns true if polling should retry once a specific block is reached.
§Returns
true for the TryOnBlock variant, false otherwise.
Sourcepub const fn is_try_at_epoch(&self) -> bool
pub const fn is_try_at_epoch(&self) -> bool
Returns true if polling should retry once a specific Unix epoch is reached.
§Returns
true for the TryAtEpoch variant, false otherwise.
Sourcepub const fn is_unexpected_error(&self) -> bool
pub const fn is_unexpected_error(&self) -> bool
Returns true if an unexpected error occurred during polling.
§Returns
true for the UnexpectedError variant, false otherwise.
Sourcepub const fn is_dont_try_again(&self) -> bool
pub const fn is_dont_try_again(&self) -> bool
Returns true if this order should never be polled again (terminal failure).
§Returns
true for the DontTryAgain variant, false otherwise.
Sourcepub const fn get_block_number(&self) -> Option<u64>
pub const fn get_block_number(&self) -> Option<u64>
Extract the target block number from a TryOnBlock variant.
Returns None for all other variants.
use cow_composable::PollResult;
let r = PollResult::TryOnBlock { block_number: 12_345_678 };
assert_eq!(r.get_block_number(), Some(12_345_678));
assert_eq!(PollResult::TryNextBlock.get_block_number(), None);Sourcepub const fn get_epoch(&self) -> Option<u64>
pub const fn get_epoch(&self) -> Option<u64>
Extract the target Unix epoch from a TryAtEpoch variant.
Returns None for all other variants.
use cow_composable::PollResult;
let r = PollResult::TryAtEpoch { epoch: 1_700_000_000 };
assert_eq!(r.get_epoch(), Some(1_700_000_000));
assert_eq!(PollResult::TryNextBlock.get_epoch(), None);Sourcepub const fn order_ref(&self) -> Option<&UnsignedOrder>
pub const fn order_ref(&self) -> Option<&UnsignedOrder>
Extract the resolved UnsignedOrder
from a PollResult::Success variant, if present.
Returns None for all other variants, or when order is None
inside Success (e.g. an offline validity check result).
Sourcepub const fn as_error_message(&self) -> Option<&str>
pub const fn as_error_message(&self) -> Option<&str>
Extract the error message from an UnexpectedError
or DontTryAgain variant.
Returns None for all other variants.
Trait Implementations§
Source§impl Clone for PollResult
impl Clone for PollResult
Source§fn clone(&self) -> PollResult
fn clone(&self) -> PollResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PollResult
impl Debug for PollResult
Auto Trait Implementations§
impl Freeze for PollResult
impl RefUnwindSafe for PollResult
impl Send for PollResult
impl Sync for PollResult
impl Unpin for PollResult
impl UnsafeUnpin for PollResult
impl UnwindSafe for PollResult
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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.