Struct CancelOrderRequest
pub struct CancelOrderRequest {
pub market: Arc<str>,
pub market_id: MarketId,
pub account: Arc<str>,
pub account_id: AccountId,
pub order_id: Option<u128>,
pub client_order_id: Option<Arc<str>>,
}Expand description
Request to cancel an existing order in the matching engine.
This structure represents a request to cancel one or more orders for a specific account
in a given market. Naming an order — by order_id or by client_order_id —
cancels only that one. Only when both are absent does the request cancel
every order the account holds in the market.
§Field Aliases
The structure supports shorter field aliases for efficient serialization:
marketcan be aliased asmaccountcan be aliased assaorder_idcan be aliased asoidclient_order_idcan be aliased ascid
§Order ID Format
The order_id field accepts both string and numeric representations, supporting very large
numbers (up to 128-bit integers) which may exceed JSON’s native number precision.
§Examples
§Cancel a specific order using full field names
{
"market": "0x5efc5ad00c209baf4c5d77dfd1be18e8b50916e53adbe2142ae1b47af445303c",
"account": "0xcc6ebf909253ea35314bb28d91321f6415827c01790fba84aaf570c87372850a",
"order_id": "340282366920938463463374607431768211455"
}§Cancel a specific order using field aliases
{
"m": "0x5efc5ad00c209baf4c5d77dfd1be18e8b50916e53adbe2142ae1b47af445303c",
"sa": "0xcc6ebf909253ea35314bb28d91321f6415827c01790fba84aaf570c87372850a",
"oid": 12345678901234567890
}§Cancel one order by the client id it was submitted with
{
"market": "0x5efc5ad00c209baf4c5d77dfd1be18e8b50916e53adbe2142ae1b47af445303c",
"account": "0xcc6ebf909253ea35314bb28d91321f6415827c01790fba84aaf570c87372850a",
"client_order_id": "my-exit-001"
}§Cancel every order for the account in the market (omit both ids)
{
"market": "0x5efc5ad00c209baf4c5d77dfd1be18e8b50916e53adbe2142ae1b47af445303c",
"account": "0xcc6ebf909253ea35314bb28d91321f6415827c01790fba84aaf570c87372850a"
}§Validation
The request will be validated to ensure:
- The market field is not empty and the market exists (201 / 202)
- The account field is not empty (203)
order_idandclient_order_idare not both set (204)
Fields§
§market: Arc<str>The market identifier where the order should be canceled.
This field is required and must match an existing market in the system. Can be provided using the alias “m” for compact serialization.
market_id: MarketId§account: Arc<str>The account identifier that owns the order(s) to be canceled.
This field is required and identifies which account’s orders should be canceled. Can be provided using the alias “sa” for compact serialization.
account_id: AccountId§order_id: Option<u128>Optional specific order ID to cancel.
If provided, only the order with this specific ID will be canceled. If omitted (None), all orders for the account in the specified market will be canceled.
Accepts both string and numeric formats to handle large 128-bit integers that may exceed JSON’s native number precision. Can be provided using the alias “oid”.
client_order_id: Option<Arc<str>>Optional client-assigned order ID to cancel.
Alternative to order_id: if provided, the order the client tagged with this
id will be canceled. Mutually exclusive with order_id — supplying both is a
validation error. Can be provided using the alias “cid”.
Implementations§
§impl CancelOrderRequest
impl CancelOrderRequest
pub fn builder() -> CancelOrderRequestBuilder
pub fn builder() -> CancelOrderRequestBuilder
Creates a new builder for constructing a CancelOrderRequest.
This is the recommended way to create new CancelOrderRequest instances,
as it ensures all required fields are properly validated before construction.
§Returns
A new CancelOrderRequestBuilder instance
§Examples
use types::api::cancel_order::CancelOrderRequest;
let request = CancelOrderRequest::builder()
.market("0x123")
.account("0x123")
.order_id(12345678901234567890u128)
.build()
.expect("Failed to build cancel order request");Trait Implementations§
§impl Clone for CancelOrderRequest
impl Clone for CancelOrderRequest
§fn clone(&self) -> CancelOrderRequest
fn clone(&self) -> CancelOrderRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for CancelOrderRequest
impl Debug for CancelOrderRequest
§impl<'de> Deserialize<'de> for CancelOrderRequest
impl<'de> Deserialize<'de> for CancelOrderRequest
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CancelOrderRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CancelOrderRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl From<CancelOrderRequest> for Command
impl From<CancelOrderRequest> for Command
§fn from(value: CancelOrderRequest) -> Command
fn from(value: CancelOrderRequest) -> Command
§impl Serialize for CancelOrderRequest
impl Serialize for CancelOrderRequest
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for CancelOrderRequest
impl RefUnwindSafe for CancelOrderRequest
impl Send for CancelOrderRequest
impl Sync for CancelOrderRequest
impl Unpin for CancelOrderRequest
impl UnsafeUnpin for CancelOrderRequest
impl UnwindSafe for CancelOrderRequest
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].impl<T> MaybeSend for Twhere
T: Send,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.