1use ibc::core::primitives::prelude::*;
2use ibc_proto::cosmos::base::query::v1beta1::{
3 PageRequest as RawPageRequest, PageResponse as RawPageResponse,
4};
5
6pub type Proof = Vec<u8>;
7
8#[derive(Clone, Debug, Default)]
9#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
11pub struct PageRequest {
12 pub key: Vec<u8>,
16 pub offset: u64,
20 pub limit: u64,
23 pub count_total: bool,
28 pub reverse: bool,
30}
31
32impl PageRequest {
33 pub fn all() -> Self {
34 Self {
35 limit: u64::MAX,
36 ..Default::default()
37 }
38 }
39}
40
41impl From<PageRequest> for RawPageRequest {
42 fn from(request: PageRequest) -> Self {
43 Self {
44 key: request.key,
45 offset: request.offset,
46 limit: request.limit,
47 count_total: request.count_total,
48 reverse: request.reverse,
49 }
50 }
51}
52
53impl From<RawPageRequest> for PageRequest {
54 fn from(request: RawPageRequest) -> Self {
55 Self {
56 key: request.key,
57 offset: request.offset,
58 limit: request.limit,
59 count_total: request.count_total,
60 reverse: request.reverse,
61 }
62 }
63}
64
65#[derive(Clone, Debug, Default)]
66#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
67#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
68pub struct PageResponse {
69 pub next_key: Vec<u8>,
73 pub total: u64,
76}
77
78impl From<PageResponse> for RawPageResponse {
79 fn from(response: PageResponse) -> Self {
80 Self {
81 next_key: response.next_key,
82 total: response.total,
83 }
84 }
85}
86
87impl From<RawPageResponse> for PageResponse {
88 fn from(response: RawPageResponse) -> Self {
89 Self {
90 next_key: response.next_key,
91 total: response.total,
92 }
93 }
94}