nautilus_binance/spot/sbe/generated/
account_commission_response_codec.rs1pub use decoder::AccountCommissionResponseDecoder;
2pub use encoder::AccountCommissionResponseEncoder;
3
4use super::*;
5pub use super::{SBE_SCHEMA_ID, SBE_SCHEMA_VERSION, SBE_SEMANTIC_VERSION};
6
7pub const SBE_BLOCK_LENGTH: u16 = 108;
8pub const SBE_TEMPLATE_ID: u16 = 405;
9
10pub mod encoder {
11 use message_header_codec::*;
12
13 use super::*;
14
15 #[derive(Debug, Default)]
16 pub struct AccountCommissionResponseEncoder<'a> {
17 buf: WriteBuf<'a>,
18 initial_offset: usize,
19 offset: usize,
20 limit: usize,
21 }
22
23 impl<'a> Writer<'a> for AccountCommissionResponseEncoder<'a> {
24 #[inline]
25 fn get_buf_mut(&mut self) -> &mut WriteBuf<'a> {
26 &mut self.buf
27 }
28 }
29
30 impl<'a> Encoder<'a> for AccountCommissionResponseEncoder<'a> {
31 #[inline]
32 fn get_limit(&self) -> usize {
33 self.limit
34 }
35
36 #[inline]
37 fn set_limit(&mut self, limit: usize) {
38 self.limit = limit;
39 }
40 }
41
42 impl<'a> AccountCommissionResponseEncoder<'a> {
43 pub fn wrap(mut self, buf: WriteBuf<'a>, offset: usize) -> Self {
44 let limit = offset + SBE_BLOCK_LENGTH as usize;
45 self.buf = buf;
46 self.initial_offset = offset;
47 self.offset = offset;
48 self.limit = limit;
49 self
50 }
51
52 #[inline]
53 pub fn encoded_length(&self) -> usize {
54 self.limit - self.offset
55 }
56
57 pub fn header(self, offset: usize) -> MessageHeaderEncoder<Self> {
58 let mut header = MessageHeaderEncoder::default().wrap(self, offset);
59 header.block_length(SBE_BLOCK_LENGTH);
60 header.template_id(SBE_TEMPLATE_ID);
61 header.schema_id(SBE_SCHEMA_ID);
62 header.version(SBE_SCHEMA_VERSION);
63 header
64 }
65
66 #[inline]
76 pub fn commission_exponent(&mut self, value: i8) {
77 let offset = self.offset;
78 self.get_buf_mut().put_i8_at(offset, value);
79 }
80
81 #[inline]
91 pub fn discount_exponent(&mut self, value: i8) {
92 let offset = self.offset + 1;
93 self.get_buf_mut().put_i8_at(offset, value);
94 }
95
96 #[inline]
106 pub fn standard_commission_maker(&mut self, value: i64) {
107 let offset = self.offset + 2;
108 self.get_buf_mut().put_i64_at(offset, value);
109 }
110
111 #[inline]
121 pub fn standard_commission_taker(&mut self, value: i64) {
122 let offset = self.offset + 10;
123 self.get_buf_mut().put_i64_at(offset, value);
124 }
125
126 #[inline]
136 pub fn standard_commission_buyer(&mut self, value: i64) {
137 let offset = self.offset + 18;
138 self.get_buf_mut().put_i64_at(offset, value);
139 }
140
141 #[inline]
151 pub fn standard_commission_seller(&mut self, value: i64) {
152 let offset = self.offset + 26;
153 self.get_buf_mut().put_i64_at(offset, value);
154 }
155
156 #[inline]
166 pub fn tax_commission_maker(&mut self, value: i64) {
167 let offset = self.offset + 34;
168 self.get_buf_mut().put_i64_at(offset, value);
169 }
170
171 #[inline]
181 pub fn tax_commission_taker(&mut self, value: i64) {
182 let offset = self.offset + 42;
183 self.get_buf_mut().put_i64_at(offset, value);
184 }
185
186 #[inline]
196 pub fn tax_commission_buyer(&mut self, value: i64) {
197 let offset = self.offset + 50;
198 self.get_buf_mut().put_i64_at(offset, value);
199 }
200
201 #[inline]
211 pub fn tax_commission_seller(&mut self, value: i64) {
212 let offset = self.offset + 58;
213 self.get_buf_mut().put_i64_at(offset, value);
214 }
215
216 #[inline]
218 pub fn discount_enabled_for_account(&mut self, value: bool_enum::BoolEnum) {
219 let offset = self.offset + 66;
220 self.get_buf_mut().put_u8_at(offset, value as u8)
221 }
222
223 #[inline]
225 pub fn discount_enabled_for_symbol(&mut self, value: bool_enum::BoolEnum) {
226 let offset = self.offset + 67;
227 self.get_buf_mut().put_u8_at(offset, value as u8)
228 }
229
230 #[inline]
240 pub fn discount(&mut self, value: i64) {
241 let offset = self.offset + 68;
242 self.get_buf_mut().put_i64_at(offset, value);
243 }
244
245 #[inline]
255 pub fn special_commission_maker(&mut self, value: i64) {
256 let offset = self.offset + 76;
257 self.get_buf_mut().put_i64_at(offset, value);
258 }
259
260 #[inline]
270 pub fn special_commission_taker(&mut self, value: i64) {
271 let offset = self.offset + 84;
272 self.get_buf_mut().put_i64_at(offset, value);
273 }
274
275 #[inline]
285 pub fn special_commission_buyer(&mut self, value: i64) {
286 let offset = self.offset + 92;
287 self.get_buf_mut().put_i64_at(offset, value);
288 }
289
290 #[inline]
300 pub fn special_commission_seller(&mut self, value: i64) {
301 let offset = self.offset + 100;
302 self.get_buf_mut().put_i64_at(offset, value);
303 }
304
305 #[inline]
307 pub fn symbol(&mut self, value: &str) {
308 let limit = self.get_limit();
309 let data_length = value.len();
310 self.set_limit(limit + 1 + data_length);
311 self.get_buf_mut().put_u8_at(limit, data_length as u8);
312 self.get_buf_mut().put_slice_at(limit + 1, value.as_bytes());
313 }
314
315 #[inline]
317 pub fn discount_asset(&mut self, value: &str) {
318 let limit = self.get_limit();
319 let data_length = value.len();
320 self.set_limit(limit + 1 + data_length);
321 self.get_buf_mut().put_u8_at(limit, data_length as u8);
322 self.get_buf_mut().put_slice_at(limit + 1, value.as_bytes());
323 }
324 }
325} pub mod decoder {
328 use message_header_codec::*;
329
330 use super::*;
331
332 #[derive(Clone, Copy, Debug, Default)]
333 pub struct AccountCommissionResponseDecoder<'a> {
334 buf: ReadBuf<'a>,
335 initial_offset: usize,
336 offset: usize,
337 limit: usize,
338 pub acting_block_length: u16,
339 pub acting_version: u16,
340 }
341
342 impl ActingVersion for AccountCommissionResponseDecoder<'_> {
343 #[inline]
344 fn acting_version(&self) -> u16 {
345 self.acting_version
346 }
347 }
348
349 impl<'a> Reader<'a> for AccountCommissionResponseDecoder<'a> {
350 #[inline]
351 fn get_buf(&self) -> &ReadBuf<'a> {
352 &self.buf
353 }
354 }
355
356 impl<'a> Decoder<'a> for AccountCommissionResponseDecoder<'a> {
357 #[inline]
358 fn get_limit(&self) -> usize {
359 self.limit
360 }
361
362 #[inline]
363 fn set_limit(&mut self, limit: usize) {
364 self.limit = limit;
365 }
366 }
367
368 impl<'a> AccountCommissionResponseDecoder<'a> {
369 pub fn wrap(
370 mut self,
371 buf: ReadBuf<'a>,
372 offset: usize,
373 acting_block_length: u16,
374 acting_version: u16,
375 ) -> Self {
376 let limit = offset + acting_block_length as usize;
377 self.buf = buf;
378 self.initial_offset = offset;
379 self.offset = offset;
380 self.limit = limit;
381 self.acting_block_length = acting_block_length;
382 self.acting_version = acting_version;
383 self
384 }
385
386 #[inline]
387 pub fn encoded_length(&self) -> usize {
388 self.limit - self.offset
389 }
390
391 pub fn header(self, mut header: MessageHeaderDecoder<ReadBuf<'a>>, offset: usize) -> Self {
392 debug_assert_eq!(SBE_TEMPLATE_ID, header.template_id());
393 let acting_block_length = header.block_length();
394 let acting_version = header.version();
395
396 self.wrap(
397 header.parent().unwrap(),
398 offset + message_header_codec::ENCODED_LENGTH,
399 acting_block_length,
400 acting_version,
401 )
402 }
403
404 #[inline]
406 pub fn commission_exponent(&self) -> i8 {
407 self.get_buf().get_i8_at(self.offset)
408 }
409
410 #[inline]
412 pub fn discount_exponent(&self) -> i8 {
413 self.get_buf().get_i8_at(self.offset + 1)
414 }
415
416 #[inline]
418 pub fn standard_commission_maker(&self) -> i64 {
419 self.get_buf().get_i64_at(self.offset + 2)
420 }
421
422 #[inline]
424 pub fn standard_commission_taker(&self) -> i64 {
425 self.get_buf().get_i64_at(self.offset + 10)
426 }
427
428 #[inline]
430 pub fn standard_commission_buyer(&self) -> i64 {
431 self.get_buf().get_i64_at(self.offset + 18)
432 }
433
434 #[inline]
436 pub fn standard_commission_seller(&self) -> i64 {
437 self.get_buf().get_i64_at(self.offset + 26)
438 }
439
440 #[inline]
442 pub fn tax_commission_maker(&self) -> i64 {
443 self.get_buf().get_i64_at(self.offset + 34)
444 }
445
446 #[inline]
448 pub fn tax_commission_taker(&self) -> i64 {
449 self.get_buf().get_i64_at(self.offset + 42)
450 }
451
452 #[inline]
454 pub fn tax_commission_buyer(&self) -> i64 {
455 self.get_buf().get_i64_at(self.offset + 50)
456 }
457
458 #[inline]
460 pub fn tax_commission_seller(&self) -> i64 {
461 self.get_buf().get_i64_at(self.offset + 58)
462 }
463
464 #[inline]
466 pub fn discount_enabled_for_account(&self) -> bool_enum::BoolEnum {
467 self.get_buf().get_u8_at(self.offset + 66).into()
468 }
469
470 #[inline]
472 pub fn discount_enabled_for_symbol(&self) -> bool_enum::BoolEnum {
473 self.get_buf().get_u8_at(self.offset + 67).into()
474 }
475
476 #[inline]
478 pub fn discount(&self) -> i64 {
479 self.get_buf().get_i64_at(self.offset + 68)
480 }
481
482 #[inline]
484 pub fn special_commission_maker(&self) -> Option<i64> {
485 if self.acting_version() < 1 {
486 return None;
487 }
488
489 let value = self.get_buf().get_i64_at(self.offset + 76);
490 if value == -9223372036854775808_i64 {
491 None
492 } else {
493 Some(value)
494 }
495 }
496
497 #[inline]
499 pub fn special_commission_taker(&self) -> Option<i64> {
500 if self.acting_version() < 1 {
501 return None;
502 }
503
504 let value = self.get_buf().get_i64_at(self.offset + 84);
505 if value == -9223372036854775808_i64 {
506 None
507 } else {
508 Some(value)
509 }
510 }
511
512 #[inline]
514 pub fn special_commission_buyer(&self) -> Option<i64> {
515 if self.acting_version() < 1 {
516 return None;
517 }
518
519 let value = self.get_buf().get_i64_at(self.offset + 92);
520 if value == -9223372036854775808_i64 {
521 None
522 } else {
523 Some(value)
524 }
525 }
526
527 #[inline]
529 pub fn special_commission_seller(&self) -> Option<i64> {
530 if self.acting_version() < 1 {
531 return None;
532 }
533
534 let value = self.get_buf().get_i64_at(self.offset + 100);
535 if value == -9223372036854775808_i64 {
536 None
537 } else {
538 Some(value)
539 }
540 }
541
542 #[inline]
544 pub fn symbol_decoder(&mut self) -> (usize, usize) {
545 let offset = self.get_limit();
546 let data_length = self.get_buf().get_u8_at(offset) as usize;
547 self.set_limit(offset + 1 + data_length);
548 (offset + 1, data_length)
549 }
550
551 #[inline]
552 pub fn symbol_slice(&'a self, coordinates: (usize, usize)) -> &'a [u8] {
553 debug_assert!(self.get_limit() >= coordinates.0 + coordinates.1);
554 self.get_buf().get_slice_at(coordinates.0, coordinates.1)
555 }
556
557 #[inline]
559 pub fn discount_asset_decoder(&mut self) -> (usize, usize) {
560 let offset = self.get_limit();
561 let data_length = self.get_buf().get_u8_at(offset) as usize;
562 self.set_limit(offset + 1 + data_length);
563 (offset + 1, data_length)
564 }
565
566 #[inline]
567 pub fn discount_asset_slice(&'a self, coordinates: (usize, usize)) -> &'a [u8] {
568 debug_assert!(self.get_limit() >= coordinates.0 + coordinates.1);
569 self.get_buf().get_slice_at(coordinates.0, coordinates.1)
570 }
571 }
572}