persistence_std/types/cosmos/orm/query/
v1alpha1.rs

1use persistence_std_derive::CosmwasmExt;
2/// GetRequest is the Query/Get request type.
3#[allow(clippy::derive_partial_eq_without_eq)]
4#[derive(
5    Clone,
6    PartialEq,
7    Eq,
8    ::prost::Message,
9    ::serde::Serialize,
10    ::serde::Deserialize,
11    ::schemars::JsonSchema,
12    CosmwasmExt,
13)]
14#[proto_message(type_url = "/cosmos.orm.query.v1alpha1.GetRequest")]
15#[proto_query(
16    path = "/cosmos.orm.query.v1alpha1.Query/Get",
17    response_type = GetResponse
18)]
19pub struct GetRequest {
20    /// message_name is the fully-qualified message name of the ORM table being queried.
21    #[prost(string, tag = "1")]
22    pub message_name: ::prost::alloc::string::String,
23    /// index is the index fields expression used in orm definitions. If it
24    /// is empty, the table's primary key is assumed. If it is non-empty, it must
25    /// refer to an unique index.
26    #[prost(string, tag = "2")]
27    pub index: ::prost::alloc::string::String,
28    /// values are the values of the fields corresponding to the requested index.
29    /// There must be as many values provided as there are fields in the index and
30    /// these values must correspond to the index field types.
31    #[prost(message, repeated, tag = "3")]
32    pub values: ::prost::alloc::vec::Vec<IndexValue>,
33}
34/// GetResponse is the Query/Get response type.
35#[allow(clippy::derive_partial_eq_without_eq)]
36#[derive(
37    Clone,
38    PartialEq,
39    Eq,
40    ::prost::Message,
41    ::serde::Serialize,
42    ::serde::Deserialize,
43    ::schemars::JsonSchema,
44    CosmwasmExt,
45)]
46#[proto_message(type_url = "/cosmos.orm.query.v1alpha1.GetResponse")]
47pub struct GetResponse {
48    /// result is the result of the get query. If no value is found, the gRPC
49    /// status code NOT_FOUND will be returned.
50    #[prost(message, optional, tag = "1")]
51    pub result: ::core::option::Option<crate::shim::Any>,
52}
53/// ListRequest is the Query/List request type.
54#[allow(clippy::derive_partial_eq_without_eq)]
55#[derive(
56    Clone,
57    PartialEq,
58    Eq,
59    ::prost::Message,
60    ::serde::Serialize,
61    ::serde::Deserialize,
62    ::schemars::JsonSchema,
63    CosmwasmExt,
64)]
65#[proto_message(type_url = "/cosmos.orm.query.v1alpha1.ListRequest")]
66#[proto_query(
67    path = "/cosmos.orm.query.v1alpha1.Query/List",
68    response_type = ListResponse
69)]
70pub struct ListRequest {
71    /// message_name is the fully-qualified message name of the ORM table being queried.
72    #[prost(string, tag = "1")]
73    pub message_name: ::prost::alloc::string::String,
74    /// index is the index fields expression used in orm definitions. If it
75    /// is empty, the table's primary key is assumed.
76    #[prost(string, tag = "2")]
77    pub index: ::prost::alloc::string::String,
78    /// pagination is the pagination request.
79    #[prost(message, optional, tag = "5")]
80    pub pagination: ::core::option::Option<super::super::super::base::query::v1beta1::PageRequest>,
81    /// query is the query expression corresponding to the provided index. If
82    /// neither prefix nor range is specified, the query will list all the fields
83    /// in the index.
84    #[prost(oneof = "list_request::Query", tags = "3, 4")]
85    pub query: ::core::option::Option<list_request::Query>,
86}
87/// Nested message and enum types in `ListRequest`.
88pub mod list_request {
89    use persistence_std_derive::CosmwasmExt;
90    /// Prefix specifies the arguments to a prefix query.
91    #[allow(clippy::derive_partial_eq_without_eq)]
92    #[derive(
93        Clone,
94        PartialEq,
95        Eq,
96        ::prost::Message,
97        ::serde::Serialize,
98        ::serde::Deserialize,
99        ::schemars::JsonSchema,
100        CosmwasmExt,
101    )]
102    #[proto_message(type_url = "/cosmos.orm.query.v1alpha1.ListRequest.Prefix")]
103    pub struct Prefix {
104        /// values specifies the index values for the prefix query.
105        /// It is valid to special a partial prefix with fewer values than
106        /// the number of fields in the index.
107        #[prost(message, repeated, tag = "1")]
108        pub values: ::prost::alloc::vec::Vec<super::IndexValue>,
109    }
110    /// Range specifies the arguments to a range query.
111    #[allow(clippy::derive_partial_eq_without_eq)]
112    #[derive(
113        Clone,
114        PartialEq,
115        Eq,
116        ::prost::Message,
117        ::serde::Serialize,
118        ::serde::Deserialize,
119        ::schemars::JsonSchema,
120        CosmwasmExt,
121    )]
122    #[proto_message(type_url = "/cosmos.orm.query.v1alpha1.ListRequest.Range")]
123    pub struct Range {
124        /// start specifies the starting index values for the range query.
125        /// It is valid to provide fewer values than the number of fields in the
126        /// index.
127        #[prost(message, repeated, tag = "1")]
128        pub start: ::prost::alloc::vec::Vec<super::IndexValue>,
129        /// end specifies the inclusive ending index values for the range query.
130        /// It is valid to provide fewer values than the number of fields in the
131        /// index.
132        #[prost(message, repeated, tag = "2")]
133        pub end: ::prost::alloc::vec::Vec<super::IndexValue>,
134    }
135    /// query is the query expression corresponding to the provided index. If
136    /// neither prefix nor range is specified, the query will list all the fields
137    /// in the index.
138    #[allow(clippy::derive_partial_eq_without_eq)]
139    #[derive(
140        Clone,
141        PartialEq,
142        Eq,
143        ::prost::Oneof,
144        ::schemars::JsonSchema,
145        ::serde::Serialize,
146        ::serde::Deserialize,
147    )]
148    pub enum Query {
149        /// prefix defines a prefix query.
150        #[prost(message, tag = "3")]
151        Prefix(Prefix),
152        /// range defines a range query.
153        #[prost(message, tag = "4")]
154        Range(Range),
155    }
156}
157/// ListResponse is the Query/List response type.
158#[allow(clippy::derive_partial_eq_without_eq)]
159#[derive(
160    Clone,
161    PartialEq,
162    Eq,
163    ::prost::Message,
164    ::serde::Serialize,
165    ::serde::Deserialize,
166    ::schemars::JsonSchema,
167    CosmwasmExt,
168)]
169#[proto_message(type_url = "/cosmos.orm.query.v1alpha1.ListResponse")]
170pub struct ListResponse {
171    /// results are the results of the query.
172    #[prost(message, repeated, tag = "1")]
173    pub results: ::prost::alloc::vec::Vec<crate::shim::Any>,
174    /// pagination is the pagination response.
175    #[prost(message, optional, tag = "5")]
176    pub pagination: ::core::option::Option<super::super::super::base::query::v1beta1::PageResponse>,
177}
178/// IndexValue represents the value of a field in an ORM index expression.
179#[allow(clippy::derive_partial_eq_without_eq)]
180#[derive(
181    Clone,
182    PartialEq,
183    Eq,
184    ::prost::Message,
185    ::serde::Serialize,
186    ::serde::Deserialize,
187    ::schemars::JsonSchema,
188    CosmwasmExt,
189)]
190#[proto_message(type_url = "/cosmos.orm.query.v1alpha1.IndexValue")]
191pub struct IndexValue {
192    /// value specifies the index value
193    #[prost(oneof = "index_value::Value", tags = "1, 2, 3, 4, 5, 6, 7, 8")]
194    pub value: ::core::option::Option<index_value::Value>,
195}
196/// Nested message and enum types in `IndexValue`.
197pub mod index_value {
198    use persistence_std_derive::CosmwasmExt;
199    /// value specifies the index value
200    #[allow(clippy::derive_partial_eq_without_eq)]
201    #[derive(
202        Clone,
203        PartialEq,
204        Eq,
205        ::prost::Oneof,
206        ::schemars::JsonSchema,
207        ::serde::Serialize,
208        ::serde::Deserialize,
209    )]
210    pub enum Value {
211        /// uint specifies a value for an uint32, fixed32, uint64, or fixed64
212        /// index field.
213        #[prost(uint64, tag = "1")]
214        Uint(u64),
215        /// int64 specifies a value for an int32, sfixed32, int64, or sfixed64
216        /// index field.
217        #[prost(int64, tag = "2")]
218        Int(i64),
219        /// str specifies a value for a string index field.
220        #[prost(string, tag = "3")]
221        Str(::prost::alloc::string::String),
222        /// bytes specifies a value for a bytes index field.
223        #[prost(bytes, tag = "4")]
224        Bytes(::prost::alloc::vec::Vec<u8>),
225        /// enum specifies a value for an enum index field.
226        #[prost(string, tag = "5")]
227        Enum(::prost::alloc::string::String),
228        /// bool specifies a value for a bool index field.
229        #[prost(bool, tag = "6")]
230        Bool(bool),
231        /// timestamp specifies a value for a timestamp index field.
232        #[prost(message, tag = "7")]
233        Timestamp(crate::shim::Timestamp),
234        /// duration specifies a value for a duration index field.
235        #[prost(message, tag = "8")]
236        Duration(crate::shim::Duration),
237    }
238}
239pub struct V1alpha1Querier<'a, Q: cosmwasm_std::CustomQuery> {
240    querier: &'a cosmwasm_std::QuerierWrapper<'a, Q>,
241}
242impl<'a, Q: cosmwasm_std::CustomQuery> V1alpha1Querier<'a, Q> {
243    pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, Q>) -> Self {
244        Self { querier }
245    }
246    pub fn get(
247        &self,
248        message_name: ::prost::alloc::string::String,
249        index: ::prost::alloc::string::String,
250        values: ::prost::alloc::vec::Vec<IndexValue>,
251    ) -> Result<GetResponse, cosmwasm_std::StdError> {
252        GetRequest {
253            message_name,
254            index,
255            values,
256        }
257        .query(self.querier)
258    }
259    pub fn list(
260        &self,
261        message_name: ::prost::alloc::string::String,
262        index: ::prost::alloc::string::String,
263        pagination: ::core::option::Option<super::super::super::base::query::v1beta1::PageRequest>,
264        query: ::core::option::Option<list_request::Query>,
265    ) -> Result<ListResponse, cosmwasm_std::StdError> {
266        ListRequest {
267            message_name,
268            index,
269            pagination,
270            query,
271        }
272        .query(self.querier)
273    }
274}