nautilus_binance/common/sbe/spot/
klines_response_codec.rs

1pub use decoder::KlinesResponseDecoder;
2pub use encoder::KlinesResponseEncoder;
3
4use super::*;
5pub use super::{SBE_SCHEMA_ID, SBE_SCHEMA_VERSION, SBE_SEMANTIC_VERSION};
6
7pub const SBE_BLOCK_LENGTH: u16 = 2;
8pub const SBE_TEMPLATE_ID: u16 = 203;
9
10pub mod encoder {
11    use message_header_codec::*;
12
13    use super::*;
14
15    #[derive(Debug, Default)]
16    pub struct KlinesResponseEncoder<'a> {
17        buf: WriteBuf<'a>,
18        initial_offset: usize,
19        offset: usize,
20        limit: usize,
21    }
22
23    impl<'a> Writer<'a> for KlinesResponseEncoder<'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 KlinesResponseEncoder<'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> KlinesResponseEncoder<'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        /// primitive field 'priceExponent'
67        /// - min value: -127
68        /// - max value: 127
69        /// - null value: -128_i8
70        /// - characterEncoding: null
71        /// - semanticType: null
72        /// - encodedOffset: 0
73        /// - encodedLength: 1
74        /// - version: 0
75        #[inline]
76        pub fn price_exponent(&mut self, value: i8) {
77            let offset = self.offset;
78            self.get_buf_mut().put_i8_at(offset, value);
79        }
80
81        /// primitive field 'qtyExponent'
82        /// - min value: -127
83        /// - max value: 127
84        /// - null value: -128_i8
85        /// - characterEncoding: null
86        /// - semanticType: null
87        /// - encodedOffset: 1
88        /// - encodedLength: 1
89        /// - version: 0
90        #[inline]
91        pub fn qty_exponent(&mut self, value: i8) {
92            let offset = self.offset + 1;
93            self.get_buf_mut().put_i8_at(offset, value);
94        }
95
96        /// GROUP ENCODER (id=100)
97        #[inline]
98        pub fn klines_encoder(
99            self,
100            count: u32,
101            klines_encoder: KlinesEncoder<Self>,
102        ) -> KlinesEncoder<Self> {
103            klines_encoder.wrap(self, count)
104        }
105    }
106
107    #[derive(Debug, Default)]
108    pub struct KlinesEncoder<P> {
109        parent: Option<P>,
110        count: u32,
111        index: usize,
112        offset: usize,
113        initial_limit: usize,
114    }
115
116    impl<'a, P> Writer<'a> for KlinesEncoder<P>
117    where
118        P: Writer<'a> + Default,
119    {
120        #[inline]
121        fn get_buf_mut(&mut self) -> &mut WriteBuf<'a> {
122            if let Some(parent) = self.parent.as_mut() {
123                parent.get_buf_mut()
124            } else {
125                panic!("parent was None")
126            }
127        }
128    }
129
130    impl<'a, P> Encoder<'a> for KlinesEncoder<P>
131    where
132        P: Encoder<'a> + Default,
133    {
134        #[inline]
135        fn get_limit(&self) -> usize {
136            self.parent.as_ref().expect("parent missing").get_limit()
137        }
138
139        #[inline]
140        fn set_limit(&mut self, limit: usize) {
141            self.parent
142                .as_mut()
143                .expect("parent missing")
144                .set_limit(limit);
145        }
146    }
147
148    impl<'a, P> KlinesEncoder<P>
149    where
150        P: Encoder<'a> + Default,
151    {
152        #[inline]
153        pub fn wrap(mut self, mut parent: P, count: u32) -> Self {
154            let initial_limit = parent.get_limit();
155            parent.set_limit(initial_limit + 6);
156            parent
157                .get_buf_mut()
158                .put_u16_at(initial_limit, Self::block_length());
159            parent.get_buf_mut().put_u32_at(initial_limit + 2, count);
160            self.parent = Some(parent);
161            self.count = count;
162            self.index = usize::MAX;
163            self.offset = usize::MAX;
164            self.initial_limit = initial_limit;
165            self
166        }
167
168        #[inline]
169        pub fn block_length() -> u16 {
170            120
171        }
172
173        #[inline]
174        pub fn parent(&mut self) -> SbeResult<P> {
175            self.parent.take().ok_or(SbeErr::ParentNotSet)
176        }
177
178        /// will return Some(current index) when successful otherwise None
179        #[inline]
180        pub fn advance(&mut self) -> SbeResult<Option<usize>> {
181            let index = self.index.wrapping_add(1);
182            if index >= self.count as usize {
183                return Ok(None);
184            }
185            if let Some(parent) = self.parent.as_mut() {
186                self.offset = parent.get_limit();
187                parent.set_limit(self.offset + Self::block_length() as usize);
188                self.index = index;
189                Ok(Some(index))
190            } else {
191                Err(SbeErr::ParentNotSet)
192            }
193        }
194
195        /// primitive field 'openTime'
196        /// - min value: -9223372036854775807
197        /// - max value: 9223372036854775807
198        /// - null value: -9223372036854775808_i64
199        /// - characterEncoding: null
200        /// - semanticType: null
201        /// - encodedOffset: 0
202        /// - encodedLength: 8
203        /// - version: 0
204        #[inline]
205        pub fn open_time(&mut self, value: i64) {
206            let offset = self.offset;
207            self.get_buf_mut().put_i64_at(offset, value);
208        }
209
210        /// primitive field 'openPrice'
211        /// - min value: -9223372036854775807
212        /// - max value: 9223372036854775807
213        /// - null value: -9223372036854775808_i64
214        /// - characterEncoding: null
215        /// - semanticType: null
216        /// - encodedOffset: 8
217        /// - encodedLength: 8
218        /// - version: 0
219        #[inline]
220        pub fn open_price(&mut self, value: i64) {
221            let offset = self.offset + 8;
222            self.get_buf_mut().put_i64_at(offset, value);
223        }
224
225        /// primitive field 'highPrice'
226        /// - min value: -9223372036854775807
227        /// - max value: 9223372036854775807
228        /// - null value: -9223372036854775808_i64
229        /// - characterEncoding: null
230        /// - semanticType: null
231        /// - encodedOffset: 16
232        /// - encodedLength: 8
233        /// - version: 0
234        #[inline]
235        pub fn high_price(&mut self, value: i64) {
236            let offset = self.offset + 16;
237            self.get_buf_mut().put_i64_at(offset, value);
238        }
239
240        /// primitive field 'lowPrice'
241        /// - min value: -9223372036854775807
242        /// - max value: 9223372036854775807
243        /// - null value: -9223372036854775808_i64
244        /// - characterEncoding: null
245        /// - semanticType: null
246        /// - encodedOffset: 24
247        /// - encodedLength: 8
248        /// - version: 0
249        #[inline]
250        pub fn low_price(&mut self, value: i64) {
251            let offset = self.offset + 24;
252            self.get_buf_mut().put_i64_at(offset, value);
253        }
254
255        /// primitive field 'closePrice'
256        /// - min value: -9223372036854775807
257        /// - max value: 9223372036854775807
258        /// - null value: -9223372036854775808_i64
259        /// - characterEncoding: null
260        /// - semanticType: null
261        /// - encodedOffset: 32
262        /// - encodedLength: 8
263        /// - version: 0
264        #[inline]
265        pub fn close_price(&mut self, value: i64) {
266            let offset = self.offset + 32;
267            self.get_buf_mut().put_i64_at(offset, value);
268        }
269
270        #[inline]
271        pub fn volume_at(&mut self, index: usize, value: u8) {
272            let offset = self.offset + 40;
273            let buf = self.get_buf_mut();
274            buf.put_u8_at(offset + index, value);
275        }
276
277        /// primitive array field 'volume'
278        /// - min value: 0
279        /// - max value: 254
280        /// - null value: 0xff_u8
281        /// - characterEncoding: null
282        /// - semanticType: null
283        /// - encodedOffset: 40
284        /// - encodedLength: 16
285        /// - version: 0
286        #[inline]
287        pub fn volume(&mut self, value: &[u8]) {
288            debug_assert_eq!(16, value.len());
289            let offset = self.offset + 40;
290            let buf = self.get_buf_mut();
291            buf.put_slice_at(offset, value);
292        }
293
294        /// primitive array field 'volume' from an Iterator
295        /// - min value: 0
296        /// - max value: 254
297        /// - null value: 0xff_u8
298        /// - characterEncoding: null
299        /// - semanticType: null
300        /// - encodedOffset: 40
301        /// - encodedLength: 16
302        /// - version: 0
303        #[inline]
304        pub fn volume_from_iter(&mut self, iter: impl Iterator<Item = u8>) {
305            let offset = self.offset + 40;
306            let buf = self.get_buf_mut();
307            for (i, v) in iter.enumerate() {
308                buf.put_u8_at(offset + i, v);
309            }
310        }
311
312        /// primitive array field 'volume' with zero padding
313        /// - min value: 0
314        /// - max value: 254
315        /// - null value: 0xff_u8
316        /// - characterEncoding: null
317        /// - semanticType: null
318        /// - encodedOffset: 40
319        /// - encodedLength: 16
320        /// - version: 0
321        #[inline]
322        pub fn volume_zero_padded(&mut self, value: &[u8]) {
323            let iter = value
324                .iter()
325                .copied()
326                .chain(std::iter::repeat(0_u8))
327                .take(16);
328            self.volume_from_iter(iter);
329        }
330
331        /// primitive field 'closeTime'
332        /// - min value: -9223372036854775807
333        /// - max value: 9223372036854775807
334        /// - null value: -9223372036854775808_i64
335        /// - characterEncoding: null
336        /// - semanticType: null
337        /// - encodedOffset: 56
338        /// - encodedLength: 8
339        /// - version: 0
340        #[inline]
341        pub fn close_time(&mut self, value: i64) {
342            let offset = self.offset + 56;
343            self.get_buf_mut().put_i64_at(offset, value);
344        }
345
346        #[inline]
347        pub fn quote_volume_at(&mut self, index: usize, value: u8) {
348            let offset = self.offset + 64;
349            let buf = self.get_buf_mut();
350            buf.put_u8_at(offset + index, value);
351        }
352
353        /// primitive array field 'quoteVolume'
354        /// - min value: 0
355        /// - max value: 254
356        /// - null value: 0xff_u8
357        /// - characterEncoding: null
358        /// - semanticType: null
359        /// - encodedOffset: 64
360        /// - encodedLength: 16
361        /// - version: 0
362        #[inline]
363        pub fn quote_volume(&mut self, value: &[u8]) {
364            debug_assert_eq!(16, value.len());
365            let offset = self.offset + 64;
366            let buf = self.get_buf_mut();
367            buf.put_slice_at(offset, value);
368        }
369
370        /// primitive array field 'quoteVolume' from an Iterator
371        /// - min value: 0
372        /// - max value: 254
373        /// - null value: 0xff_u8
374        /// - characterEncoding: null
375        /// - semanticType: null
376        /// - encodedOffset: 64
377        /// - encodedLength: 16
378        /// - version: 0
379        #[inline]
380        pub fn quote_volume_from_iter(&mut self, iter: impl Iterator<Item = u8>) {
381            let offset = self.offset + 64;
382            let buf = self.get_buf_mut();
383            for (i, v) in iter.enumerate() {
384                buf.put_u8_at(offset + i, v);
385            }
386        }
387
388        /// primitive array field 'quoteVolume' with zero padding
389        /// - min value: 0
390        /// - max value: 254
391        /// - null value: 0xff_u8
392        /// - characterEncoding: null
393        /// - semanticType: null
394        /// - encodedOffset: 64
395        /// - encodedLength: 16
396        /// - version: 0
397        #[inline]
398        pub fn quote_volume_zero_padded(&mut self, value: &[u8]) {
399            let iter = value
400                .iter()
401                .copied()
402                .chain(std::iter::repeat(0_u8))
403                .take(16);
404            self.quote_volume_from_iter(iter);
405        }
406
407        /// primitive field 'numTrades'
408        /// - min value: -9223372036854775807
409        /// - max value: 9223372036854775807
410        /// - null value: -9223372036854775808_i64
411        /// - characterEncoding: null
412        /// - semanticType: null
413        /// - encodedOffset: 80
414        /// - encodedLength: 8
415        /// - version: 0
416        #[inline]
417        pub fn num_trades(&mut self, value: i64) {
418            let offset = self.offset + 80;
419            self.get_buf_mut().put_i64_at(offset, value);
420        }
421
422        #[inline]
423        pub fn taker_buy_base_volume_at(&mut self, index: usize, value: u8) {
424            let offset = self.offset + 88;
425            let buf = self.get_buf_mut();
426            buf.put_u8_at(offset + index, value);
427        }
428
429        /// primitive array field 'takerBuyBaseVolume'
430        /// - min value: 0
431        /// - max value: 254
432        /// - null value: 0xff_u8
433        /// - characterEncoding: null
434        /// - semanticType: null
435        /// - encodedOffset: 88
436        /// - encodedLength: 16
437        /// - version: 0
438        #[inline]
439        pub fn taker_buy_base_volume(&mut self, value: &[u8]) {
440            debug_assert_eq!(16, value.len());
441            let offset = self.offset + 88;
442            let buf = self.get_buf_mut();
443            buf.put_slice_at(offset, value);
444        }
445
446        /// primitive array field 'takerBuyBaseVolume' from an Iterator
447        /// - min value: 0
448        /// - max value: 254
449        /// - null value: 0xff_u8
450        /// - characterEncoding: null
451        /// - semanticType: null
452        /// - encodedOffset: 88
453        /// - encodedLength: 16
454        /// - version: 0
455        #[inline]
456        pub fn taker_buy_base_volume_from_iter(&mut self, iter: impl Iterator<Item = u8>) {
457            let offset = self.offset + 88;
458            let buf = self.get_buf_mut();
459            for (i, v) in iter.enumerate() {
460                buf.put_u8_at(offset + i, v);
461            }
462        }
463
464        /// primitive array field 'takerBuyBaseVolume' with zero padding
465        /// - min value: 0
466        /// - max value: 254
467        /// - null value: 0xff_u8
468        /// - characterEncoding: null
469        /// - semanticType: null
470        /// - encodedOffset: 88
471        /// - encodedLength: 16
472        /// - version: 0
473        #[inline]
474        pub fn taker_buy_base_volume_zero_padded(&mut self, value: &[u8]) {
475            let iter = value
476                .iter()
477                .copied()
478                .chain(std::iter::repeat(0_u8))
479                .take(16);
480            self.taker_buy_base_volume_from_iter(iter);
481        }
482
483        #[inline]
484        pub fn taker_buy_quote_volume_at(&mut self, index: usize, value: u8) {
485            let offset = self.offset + 104;
486            let buf = self.get_buf_mut();
487            buf.put_u8_at(offset + index, value);
488        }
489
490        /// primitive array field 'takerBuyQuoteVolume'
491        /// - min value: 0
492        /// - max value: 254
493        /// - null value: 0xff_u8
494        /// - characterEncoding: null
495        /// - semanticType: null
496        /// - encodedOffset: 104
497        /// - encodedLength: 16
498        /// - version: 0
499        #[inline]
500        pub fn taker_buy_quote_volume(&mut self, value: &[u8]) {
501            debug_assert_eq!(16, value.len());
502            let offset = self.offset + 104;
503            let buf = self.get_buf_mut();
504            buf.put_slice_at(offset, value);
505        }
506
507        /// primitive array field 'takerBuyQuoteVolume' from an Iterator
508        /// - min value: 0
509        /// - max value: 254
510        /// - null value: 0xff_u8
511        /// - characterEncoding: null
512        /// - semanticType: null
513        /// - encodedOffset: 104
514        /// - encodedLength: 16
515        /// - version: 0
516        #[inline]
517        pub fn taker_buy_quote_volume_from_iter(&mut self, iter: impl Iterator<Item = u8>) {
518            let offset = self.offset + 104;
519            let buf = self.get_buf_mut();
520            for (i, v) in iter.enumerate() {
521                buf.put_u8_at(offset + i, v);
522            }
523        }
524
525        /// primitive array field 'takerBuyQuoteVolume' with zero padding
526        /// - min value: 0
527        /// - max value: 254
528        /// - null value: 0xff_u8
529        /// - characterEncoding: null
530        /// - semanticType: null
531        /// - encodedOffset: 104
532        /// - encodedLength: 16
533        /// - version: 0
534        #[inline]
535        pub fn taker_buy_quote_volume_zero_padded(&mut self, value: &[u8]) {
536            let iter = value
537                .iter()
538                .copied()
539                .chain(std::iter::repeat(0_u8))
540                .take(16);
541            self.taker_buy_quote_volume_from_iter(iter);
542        }
543    }
544} // end encoder
545
546pub mod decoder {
547    use message_header_codec::*;
548
549    use super::*;
550
551    #[derive(Clone, Copy, Debug, Default)]
552    pub struct KlinesResponseDecoder<'a> {
553        buf: ReadBuf<'a>,
554        initial_offset: usize,
555        offset: usize,
556        limit: usize,
557        pub acting_block_length: u16,
558        pub acting_version: u16,
559    }
560
561    impl ActingVersion for KlinesResponseDecoder<'_> {
562        #[inline]
563        fn acting_version(&self) -> u16 {
564            self.acting_version
565        }
566    }
567
568    impl<'a> Reader<'a> for KlinesResponseDecoder<'a> {
569        #[inline]
570        fn get_buf(&self) -> &ReadBuf<'a> {
571            &self.buf
572        }
573    }
574
575    impl<'a> Decoder<'a> for KlinesResponseDecoder<'a> {
576        #[inline]
577        fn get_limit(&self) -> usize {
578            self.limit
579        }
580
581        #[inline]
582        fn set_limit(&mut self, limit: usize) {
583            self.limit = limit;
584        }
585    }
586
587    impl<'a> KlinesResponseDecoder<'a> {
588        pub fn wrap(
589            mut self,
590            buf: ReadBuf<'a>,
591            offset: usize,
592            acting_block_length: u16,
593            acting_version: u16,
594        ) -> Self {
595            let limit = offset + acting_block_length as usize;
596            self.buf = buf;
597            self.initial_offset = offset;
598            self.offset = offset;
599            self.limit = limit;
600            self.acting_block_length = acting_block_length;
601            self.acting_version = acting_version;
602            self
603        }
604
605        #[inline]
606        pub fn encoded_length(&self) -> usize {
607            self.limit - self.offset
608        }
609
610        pub fn header(self, mut header: MessageHeaderDecoder<ReadBuf<'a>>, offset: usize) -> Self {
611            debug_assert_eq!(SBE_TEMPLATE_ID, header.template_id());
612            let acting_block_length = header.block_length();
613            let acting_version = header.version();
614
615            self.wrap(
616                header.parent().unwrap(),
617                offset + message_header_codec::ENCODED_LENGTH,
618                acting_block_length,
619                acting_version,
620            )
621        }
622
623        /// primitive field - 'REQUIRED'
624        #[inline]
625        pub fn price_exponent(&self) -> i8 {
626            self.get_buf().get_i8_at(self.offset)
627        }
628
629        /// primitive field - 'REQUIRED'
630        #[inline]
631        pub fn qty_exponent(&self) -> i8 {
632            self.get_buf().get_i8_at(self.offset + 1)
633        }
634
635        /// GROUP DECODER (id=100)
636        #[inline]
637        pub fn klines_decoder(self) -> KlinesDecoder<Self> {
638            KlinesDecoder::default().wrap(self)
639        }
640    }
641
642    #[derive(Debug, Default)]
643    pub struct KlinesDecoder<P> {
644        parent: Option<P>,
645        block_length: u16,
646        count: u32,
647        index: usize,
648        offset: usize,
649    }
650
651    impl<'a, P> ActingVersion for KlinesDecoder<P>
652    where
653        P: Reader<'a> + ActingVersion + Default,
654    {
655        #[inline]
656        fn acting_version(&self) -> u16 {
657            self.parent.as_ref().unwrap().acting_version()
658        }
659    }
660
661    impl<'a, P> Reader<'a> for KlinesDecoder<P>
662    where
663        P: Reader<'a> + Default,
664    {
665        #[inline]
666        fn get_buf(&self) -> &ReadBuf<'a> {
667            self.parent.as_ref().expect("parent missing").get_buf()
668        }
669    }
670
671    impl<'a, P> Decoder<'a> for KlinesDecoder<P>
672    where
673        P: Decoder<'a> + ActingVersion + Default,
674    {
675        #[inline]
676        fn get_limit(&self) -> usize {
677            self.parent.as_ref().expect("parent missing").get_limit()
678        }
679
680        #[inline]
681        fn set_limit(&mut self, limit: usize) {
682            self.parent
683                .as_mut()
684                .expect("parent missing")
685                .set_limit(limit);
686        }
687    }
688
689    impl<'a, P> KlinesDecoder<P>
690    where
691        P: Decoder<'a> + ActingVersion + Default,
692    {
693        pub fn wrap(mut self, mut parent: P) -> Self {
694            let initial_offset = parent.get_limit();
695            let block_length = parent.get_buf().get_u16_at(initial_offset);
696            let count = parent.get_buf().get_u32_at(initial_offset + 2);
697            parent.set_limit(initial_offset + 6);
698            self.parent = Some(parent);
699            self.block_length = block_length;
700            self.count = count;
701            self.index = usize::MAX;
702            self.offset = 0;
703            self
704        }
705
706        /// group token - Token{signal=BEGIN_GROUP, name='klines', referencedName='null', description='null', packageName='null', id=100, version=0, deprecated=0, encodedLength=120, offset=2, componentTokenCount=39, encoding=Encoding{presence=REQUIRED, primitiveType=null, byteOrder=LITTLE_ENDIAN, minValue=null, maxValue=null, nullValue=null, constValue=null, characterEncoding='null', epoch='null', timeUnit=null, semanticType='null'}}
707        #[inline]
708        pub fn parent(&mut self) -> SbeResult<P> {
709            self.parent.take().ok_or(SbeErr::ParentNotSet)
710        }
711
712        #[inline]
713        pub fn acting_version(&mut self) -> u16 {
714            self.parent.as_ref().unwrap().acting_version()
715        }
716
717        #[inline]
718        pub fn count(&self) -> u32 {
719            self.count
720        }
721
722        /// will return Some(current index) when successful otherwise None
723        pub fn advance(&mut self) -> SbeResult<Option<usize>> {
724            let index = self.index.wrapping_add(1);
725            if index >= self.count as usize {
726                return Ok(None);
727            }
728            if let Some(parent) = self.parent.as_mut() {
729                self.offset = parent.get_limit();
730                parent.set_limit(self.offset + self.block_length as usize);
731                self.index = index;
732                Ok(Some(index))
733            } else {
734                Err(SbeErr::ParentNotSet)
735            }
736        }
737
738        /// primitive field - 'REQUIRED'
739        #[inline]
740        pub fn open_time(&self) -> i64 {
741            self.get_buf().get_i64_at(self.offset)
742        }
743
744        /// primitive field - 'REQUIRED'
745        #[inline]
746        pub fn open_price(&self) -> i64 {
747            self.get_buf().get_i64_at(self.offset + 8)
748        }
749
750        /// primitive field - 'REQUIRED'
751        #[inline]
752        pub fn high_price(&self) -> i64 {
753            self.get_buf().get_i64_at(self.offset + 16)
754        }
755
756        /// primitive field - 'REQUIRED'
757        #[inline]
758        pub fn low_price(&self) -> i64 {
759            self.get_buf().get_i64_at(self.offset + 24)
760        }
761
762        /// primitive field - 'REQUIRED'
763        #[inline]
764        pub fn close_price(&self) -> i64 {
765            self.get_buf().get_i64_at(self.offset + 32)
766        }
767
768        #[inline]
769        pub fn volume(&self) -> [u8; 16] {
770            let buf = self.get_buf();
771            ReadBuf::get_bytes_at(buf.data, self.offset + 40)
772        }
773
774        /// primitive field - 'REQUIRED'
775        #[inline]
776        pub fn close_time(&self) -> i64 {
777            self.get_buf().get_i64_at(self.offset + 56)
778        }
779
780        #[inline]
781        pub fn quote_volume(&self) -> [u8; 16] {
782            let buf = self.get_buf();
783            ReadBuf::get_bytes_at(buf.data, self.offset + 64)
784        }
785
786        /// primitive field - 'REQUIRED'
787        #[inline]
788        pub fn num_trades(&self) -> i64 {
789            self.get_buf().get_i64_at(self.offset + 80)
790        }
791
792        #[inline]
793        pub fn taker_buy_base_volume(&self) -> [u8; 16] {
794            let buf = self.get_buf();
795            ReadBuf::get_bytes_at(buf.data, self.offset + 88)
796        }
797
798        #[inline]
799        pub fn taker_buy_quote_volume(&self) -> [u8; 16] {
800            let buf = self.get_buf();
801            ReadBuf::get_bytes_at(buf.data, self.offset + 104)
802        }
803    }
804} // end decoder