pub struct SmallOrder {Show 15 fields
pub id: Option<Uuid>,
pub kind: Option<Kind>,
pub status: Option<Status>,
pub amount: i64,
pub fiat_code: String,
pub min_amount: Option<i64>,
pub max_amount: Option<i64>,
pub fiat_amount: i64,
pub payment_method: String,
pub premium: i64,
pub buyer_trade_pubkey: Option<String>,
pub seller_trade_pubkey: Option<String>,
pub buyer_invoice: Option<String>,
pub created_at: Option<i64>,
pub expires_at: Option<i64>,
}Expand description
Compact, wire-friendly view of an order.
SmallOrder carries the fields needed to publish a new order or to show
a listing entry to a client, without the bookkeeping fields kept in
Order (hold invoice hash, fees, dispute flags, etc.). It is the shape
used by Payload::Order and siblings.
Unknown fields are rejected at deserialization time (deny_unknown_fields).
Fields§
§id: Option<Uuid>Order id. None for orders that have not been persisted yet.
kind: Option<Kind>Order kind.
status: Option<Status>Current status.
amount: i64Sats amount. 0 when the sats amount is derived from the fiat
amount and live market price.
fiat_code: StringFiat currency code (e.g. “EUR”).
min_amount: Option<i64>Lower bound of a range order (fiat amount).
max_amount: Option<i64>Upper bound of a range order (fiat amount).
fiat_amount: i64Fiat amount of the trade.
payment_method: StringFree-form payment method description.
Premium percentage applied on top of the spot price.
buyer_trade_pubkey: Option<String>Buyer trade public key, when known.
seller_trade_pubkey: Option<String>Seller trade public key, when known.
buyer_invoice: Option<String>Buyer’s Lightning payout invoice, when already provided.
created_at: Option<i64>Unix timestamp (seconds) when the order was created.
expires_at: Option<i64>Unix timestamp (seconds) when the order expires automatically.
Implementations§
Source§impl SmallOrder
impl SmallOrder
Sourcepub fn new(
id: Option<Uuid>,
kind: Option<Kind>,
status: Option<Status>,
amount: i64,
fiat_code: String,
min_amount: Option<i64>,
max_amount: Option<i64>,
fiat_amount: i64,
payment_method: String,
premium: i64,
buyer_trade_pubkey: Option<String>,
seller_trade_pubkey: Option<String>,
buyer_invoice: Option<String>,
created_at: Option<i64>,
expires_at: Option<i64>,
) -> Self
pub fn new( id: Option<Uuid>, kind: Option<Kind>, status: Option<Status>, amount: i64, fiat_code: String, min_amount: Option<i64>, max_amount: Option<i64>, fiat_amount: i64, payment_method: String, premium: i64, buyer_trade_pubkey: Option<String>, seller_trade_pubkey: Option<String>, buyer_invoice: Option<String>, created_at: Option<i64>, expires_at: Option<i64>, ) -> Self
Construct a new SmallOrder from all of its fields.
Sourcepub fn from_json(json: &str) -> Result<Self, ServiceError>
pub fn from_json(json: &str) -> Result<Self, ServiceError>
Parse a SmallOrder from its JSON representation.
Sourcepub fn as_json(&self) -> Result<String, ServiceError>
pub fn as_json(&self) -> Result<String, ServiceError>
Serialize the order to a JSON string.
Sourcepub fn sats_amount(&self) -> String
pub fn sats_amount(&self) -> String
Return the sats amount as a string, or the literal "Market price"
when the amount is 0 (to be computed at take-time).
Sourcepub fn check_fiat_amount(&self) -> Result<(), CantDoReason>
pub fn check_fiat_amount(&self) -> Result<(), CantDoReason>
Assert that the fiat amount is strictly positive.
Returns CantDoReason::InvalidAmount otherwise.
Sourcepub fn check_amount(&self) -> Result<(), CantDoReason>
pub fn check_amount(&self) -> Result<(), CantDoReason>
Assert that the sats amount is non-negative.
A value of 0 is explicitly accepted because it signals that the
sats amount will be derived from the fiat amount and the market
price at take-time. Returns CantDoReason::InvalidAmount when the
amount is negative.
Reject orders that set both amount and premium at the same time.
A premium only makes sense when the sats amount is market-priced;
combining a fixed sats amount with a premium is ambiguous and
returns CantDoReason::InvalidParameters.
Sourcepub fn check_range_order_limits(
&self,
amounts: &mut Vec<i64>,
) -> Result<(), CantDoReason>
pub fn check_range_order_limits( &self, amounts: &mut Vec<i64>, ) -> Result<(), CantDoReason>
Validate the bounds of a range order and push them into amounts.
When both min_amount and max_amount are set, they must be
non-negative, min < max, and amount must be 0 (range orders
cannot fix the sats amount). On success, amounts is cleared and
replaced with [min, max]. On failure returns
CantDoReason::InvalidAmount.
Sourcepub fn check_fiat_currency(
&self,
fiat_currencies_accepted: &[String],
) -> Result<(), CantDoReason>
pub fn check_fiat_currency( &self, fiat_currencies_accepted: &[String], ) -> Result<(), CantDoReason>
Verify that the order’s fiat code appears in the list of accepted currencies.
An empty allowlist disables the check (every currency is accepted).
Returns CantDoReason::InvalidFiatCurrency when the currency is
not allowed.
Trait Implementations§
Source§impl Clone for SmallOrder
impl Clone for SmallOrder
Source§fn clone(&self) -> SmallOrder
fn clone(&self) -> SmallOrder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SmallOrder
impl Debug for SmallOrder
Source§impl Default for SmallOrder
impl Default for SmallOrder
Source§fn default() -> SmallOrder
fn default() -> SmallOrder
Source§impl<'de> Deserialize<'de> for SmallOrder
impl<'de> Deserialize<'de> for SmallOrder
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>,
Source§impl From<Order> for SmallOrder
impl From<Order> for SmallOrder
Source§impl From<SmallOrder> for Order
impl From<SmallOrder> for Order
Source§fn from(small_order: SmallOrder) -> Self
fn from(small_order: SmallOrder) -> Self
Auto Trait Implementations§
impl Freeze for SmallOrder
impl RefUnwindSafe for SmallOrder
impl Send for SmallOrder
impl Sync for SmallOrder
impl Unpin for SmallOrder
impl UnsafeUnpin for SmallOrder
impl UnwindSafe for SmallOrder
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 more