1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//!
//! The order POST response.
//!

pub mod ack;
pub mod fill;
pub mod full;
pub mod result;
pub mod r#type;

use self::ack::Ack;
use self::full::Full;
use self::result::Result;

use serde::Deserialize;

///
/// The `https://www.binance.com/api/v3/order` POST response.
///
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum Response {
    /// The full-type response. See the inner element description.
    Full(Full),
    /// The result-type response. See the inner element description.
    Result(Result),
    /// The ack-type response. See the inner element description.
    Ack(Ack),
}

impl Response {
    ///
    /// Returns the client order ID from the inner types.
    ///
    pub fn client_order_id(&self) -> String {
        match self {
            Response::Full(inner) => inner.client_order_id.to_owned(),
            Response::Result(inner) => inner.client_order_id.to_owned(),
            Response::Ack(inner) => inner.client_order_id.to_owned(),
        }
    }
}