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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
// @generated by buffa-codegen. DO NOT EDIT.
/// U128 represents an unsigned 128-bit integer as two fixed64 parts:
/// value = (hi \<\< 64) | lo.
///
/// Public amount fields that use U128, including ledger balances and fields
/// named amount_e18, use fixed 18-decimal scale unless their field comment says
/// otherwise. U128 can also carry raw identifiers, such as a withdraw nonce; do
/// not apply decimal scaling to those fields.
#[derive(Clone, PartialEq, Default)]
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[serde(default)]
pub struct U128 {
/// Most significant 64 bits.
///
/// Field 1: `hi`
#[serde(
rename = "hi",
with = "::buffa::json_helpers::uint64",
skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64"
)]
pub hi: u64,
/// Least significant 64 bits.
///
/// Field 2: `lo`
#[serde(
rename = "lo",
with = "::buffa::json_helpers::uint64",
skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64"
)]
pub lo: u64,
#[serde(skip)]
#[doc(hidden)]
pub __buffa_unknown_fields: ::buffa::UnknownFields,
}
impl ::core::fmt::Debug for U128 {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_struct("U128").field("hi", &self.hi).field("lo", &self.lo).finish()
}
}
impl U128 {
/// Protobuf type URL for this message, for use with `Any::pack` and
/// `Any::unpack_if`.
///
/// Format: `type.googleapis.com/<fully.qualified.TypeName>`
pub const TYPE_URL: &'static str = "type.googleapis.com/polyester.type.v1.U128";
}
::buffa::impl_default_instance!(U128);
impl ::buffa::MessageName for U128 {
const PACKAGE: &'static str = "polyester.type.v1";
const NAME: &'static str = "U128";
const FULL_NAME: &'static str = "polyester.type.v1.U128";
const TYPE_URL: &'static str = "type.googleapis.com/polyester.type.v1.U128";
}
impl ::buffa::Message for U128 {
/// Returns the total encoded size in bytes.
///
/// The result is a `u32`; the protobuf specification requires all
/// messages to fit within 2 GiB (2,147,483,647 bytes), so a
/// compliant message will never overflow this type.
#[allow(clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u32;
if self.hi != 0u64 {
size += 1u32 + ::buffa::types::FIXED64_ENCODED_LEN as u32;
}
if self.lo != 0u64 {
size += 1u32 + ::buffa::types::FIXED64_ENCODED_LEN as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if self.hi != 0u64 {
::buffa::types::put_fixed64_field(1u32, self.hi, buf);
}
if self.lo != 0u64 {
::buffa::types::put_fixed64_field(2u32, self.lo, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
fn merge_field(
&mut self,
tag: ::buffa::encoding::Tag,
buf: &mut impl ::buffa::bytes::Buf,
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::bytes::Buf as _;
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Fixed64,
)?;
self.hi = ::buffa::types::decode_fixed64(buf)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Fixed64,
)?;
self.lo = ::buffa::types::decode_fixed64(buf)?;
}
_ => {
self.__buffa_unknown_fields
.push(::buffa::encoding::decode_unknown_field(tag, buf, ctx)?);
}
}
::core::result::Result::Ok(())
}
fn clear(&mut self) {
self.hi = 0u64;
self.lo = 0u64;
self.__buffa_unknown_fields.clear();
}
}
impl ::buffa::ExtensionSet for U128 {
const PROTO_FQN: &'static str = "polyester.type.v1.U128";
fn unknown_fields(&self) -> &::buffa::UnknownFields {
&self.__buffa_unknown_fields
}
fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
&mut self.__buffa_unknown_fields
}
}
impl ::buffa::json_helpers::ProtoElemJson for U128 {
fn serialize_proto_json<S: ::serde::Serializer>(
v: &Self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
::serde::Serialize::serialize(v, s)
}
fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
<Self as ::serde::Deserialize>::deserialize(d)
}
}
#[doc(hidden)]
pub const __U128_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
type_url: "type.googleapis.com/polyester.type.v1.U128",
to_json: ::buffa::type_registry::any_to_json::<U128>,
from_json: ::buffa::type_registry::any_from_json::<U128>,
is_wkt: false,
};
#[allow(
non_camel_case_types,
dead_code,
unused_imports,
unused_qualifications,
clippy::derivable_impls,
clippy::match_single_binding,
clippy::uninlined_format_args,
clippy::doc_lazy_continuation,
clippy::module_inception
)]
pub mod __buffa {
#[allow(unused_imports)]
use super::*;
pub mod view {
#[allow(unused_imports)]
use super::*;
/// U128 represents an unsigned 128-bit integer as two fixed64 parts:
/// value = (hi \<\< 64) | lo.
///
/// Public amount fields that use U128, including ledger balances and fields
/// named amount_e18, use fixed 18-decimal scale unless their field comment says
/// otherwise. U128 can also carry raw identifiers, such as a withdraw nonce; do
/// not apply decimal scaling to those fields.
#[derive(Clone, Debug, Default)]
pub struct U128View<'a> {
/// Most significant 64 bits.
///
/// Field 1: `hi`
pub hi: u64,
/// Least significant 64 bits.
///
/// Field 2: `lo`
pub lo: u64,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for U128View<'a> {
type Owned = super::super::U128;
fn decode_view(
buf: &'a [u8],
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(
::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT,
);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Fixed64,
)?;
view.hi = ::buffa::types::decode_fixed64(&mut cur)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Fixed64,
)?;
view.lo = ::buffa::types::decode_fixed64(&mut cur)?;
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::U128, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::U128, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::U128 {
hi: self.hi,
lo: self.lo,
__buffa_unknown_fields: self
.__buffa_unknown_fields
.to_owned()?
.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for U128View<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u32;
if self.hi != 0u64 {
size += 1u32 + ::buffa::types::FIXED64_ENCODED_LEN as u32;
}
if self.lo != 0u64 {
size += 1u32 + ::buffa::types::FIXED64_ENCODED_LEN as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if self.hi != 0u64 {
::buffa::types::put_fixed64_field(1u32, self.hi, buf);
}
if self.lo != 0u64 {
::buffa::types::put_fixed64_field(2u32, self.lo, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
/// Serializes this view as protobuf JSON.
///
/// Implicit-presence fields with default values are omitted, `required`
/// fields are always emitted, explicit-presence (`optional`) fields are
/// emitted only when set, bytes fields are base64-encoded, and enum
/// values are their proto name strings.
///
/// This impl uses `serialize_map(None)` because the number of emitted
/// fields depends on default-omission rules; serializers that require
/// known map lengths (e.g. `bincode`) will return a runtime error.
/// Use the owned message type for those formats.
impl<'__a> ::serde::Serialize for U128View<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if !::buffa::json_helpers::skip_if::is_zero_u64(&self.hi) {
__map
.serialize_entry(
"hi",
&::buffa::json_helpers::ProtoJson(&self.hi),
)?;
}
if !::buffa::json_helpers::skip_if::is_zero_u64(&self.lo) {
__map
.serialize_entry(
"lo",
&::buffa::json_helpers::ProtoJson(&self.lo),
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for U128View<'a> {
const PACKAGE: &'static str = "polyester.type.v1";
const NAME: &'static str = "U128";
const FULL_NAME: &'static str = "polyester.type.v1.U128";
const TYPE_URL: &'static str = "type.googleapis.com/polyester.type.v1.U128";
}
::buffa::impl_default_view_instance!(U128View);
::buffa::impl_view_reborrow!(U128View);
/** Self-contained, `'static` owned view of a `U128` message.
Wraps [`::buffa::OwnedView`]`<`[`U128View`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required.
Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`U128View`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/
#[derive(Clone, Debug)]
pub struct U128OwnedView(::buffa::OwnedView<U128View<'static>>);
impl U128OwnedView {
/// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer.
///
/// The view borrows directly from the buffer's data; the buffer is
/// retained inside the returned handle.
///
/// # Errors
///
/// Returns [`::buffa::DecodeError`] if the buffer contains invalid
/// protobuf data.
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
U128OwnedView(::buffa::OwnedView::decode(bytes)?),
)
}
/// Decode with custom [`::buffa::DecodeOptions`] (recursion limit,
/// max message size).
///
/// # Errors
///
/// Returns [`::buffa::DecodeError`] if the buffer is invalid or
/// exceeds the configured limits.
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
U128OwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
/// Build from an owned message via an encode → decode round-trip.
///
/// # Errors
///
/// Returns [`::buffa::DecodeError`] if the re-encoded bytes are
/// somehow invalid (should not happen for well-formed messages).
pub fn from_owned(
msg: &super::super::U128,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
U128OwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
/// Borrow the full [`U128View`] with its lifetime tied to `&self`.
#[must_use]
pub fn view(&self) -> &U128View<'_> {
self.0.reborrow()
}
/// Convert to the owned message type.
///
/// # Errors
///
/// Returns an error if re-materializing preserved unknown fields
/// fails (e.g. the unknown-field limit is exceeded).
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::U128, ::buffa::DecodeError> {
self.0.to_owned_message()
}
/// The underlying bytes buffer.
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
/// Consume the handle, returning the underlying bytes buffer.
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
/// Most significant 64 bits.
///
/// Field 1: `hi`
#[must_use]
pub fn hi(&self) -> u64 {
self.0.reborrow().hi
}
/// Least significant 64 bits.
///
/// Field 2: `lo`
#[must_use]
pub fn lo(&self) -> u64 {
self.0.reborrow().lo
}
}
impl ::core::convert::From<::buffa::OwnedView<U128View<'static>>>
for U128OwnedView {
fn from(inner: ::buffa::OwnedView<U128View<'static>>) -> Self {
U128OwnedView(inner)
}
}
impl ::core::convert::From<U128OwnedView>
for ::buffa::OwnedView<U128View<'static>> {
fn from(wrapper: U128OwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<U128View<'static>>>
for U128OwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<U128View<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::U128 {
type View<'a> = U128View<'a>;
type ViewHandle = U128OwnedView;
}
impl ::serde::Serialize for U128OwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
}
/// Register this package's `Any` type entries and extension entries.
pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) {
reg.register_json_any(super::__U128_JSON_ANY);
}
}
#[doc(inline)]
pub use self::__buffa::view::U128View;
#[doc(inline)]
pub use self::__buffa::view::U128OwnedView;
#[doc(inline)]
pub use self::__buffa::register_types;