xand_api_client/
models.rs1use serde::{Deserialize, Serialize};
10use xand_api_proto::proto_models::{TransactionId, TransactionStatus};
11
12#[derive(Debug, Default, Clone)]
13pub struct Paginated<T> {
14 pub data: T,
15 pub total: u32,
16}
17
18impl<T> From<Vec<T>> for Paginated<Vec<T>> {
19 fn from(v: Vec<T>) -> Self {
20 #[allow(clippy::cast_possible_truncation)]
21 let total = v.len() as u32;
22
23 Self { total, data: v }
24 }
25}
26
27#[derive(Clone, Debug, Eq, PartialEq)]
28pub struct Paging {
29 pub page_size: u32,
31 pub page_number: u32,
33}
34
35impl Paging {
36 #[must_use]
38 pub fn all() -> Paging {
39 Paging {
40 page_size: u32::max_value(),
41 page_number: 0,
42 }
43 }
44}
45
46impl Default for Paging {
47 fn default() -> Paging {
48 Paging {
49 page_size: xand_api_proto::proto_models::DEFAULT_PAGE_SIZE,
50 page_number: 0,
51 }
52 }
53}
54
55#[derive(Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
56pub struct TransactionUpdate {
57 pub id: TransactionId,
58 pub status: TransactionStatus,
59}