xrpl_api/api/
with_pagination.rs1use crate::Request;
2use serde::{Deserialize, Serialize};
3
4pub trait WithRequestPagination: Request {
7 fn as_pagination(&self) -> &RequestPagination;
8 fn as_pagination_mut(&mut self) -> &mut RequestPagination;
9
10 fn limit(mut self, limit: u32) -> Self
11 where
12 Self: Sized,
13 {
14 self.as_pagination_mut().limit = Some(limit);
15 self
16 }
17
18 fn marker(mut self, marker: serde_json::Value) -> Self
19 where
20 Self: Sized,
21 {
22 self.as_pagination_mut().marker = Some(marker);
23 self
24 }
25}
26
27pub trait WithResponsePagination {
30 fn as_pagination(&self) -> &ResponsePagination;
31
32 fn limit(&self) -> Option<u32>
33 where
34 Self: Sized,
35 {
36 self.as_pagination().limit
37 }
38
39 fn marker(&self) -> Option<&serde_json::Value>
40 where
41 Self: Sized,
42 {
43 self.as_pagination().marker.as_ref()
44 }
45}
46
47#[derive(Default, Debug, Clone, Serialize)]
49pub struct RequestPagination {
50 #[serde(skip_serializing_if = "Option::is_none")]
51 pub limit: Option<u32>,
52 #[serde(skip_serializing_if = "Option::is_none")]
54 pub marker: Option<serde_json::Value>,
55}
56
57#[derive(Default, Debug, Clone, Deserialize)]
59pub struct ResponsePagination {
60 pub limit: Option<u32>,
61 pub marker: Option<serde_json::Value>,
63}