Skip to main content

nautilus_binance/spot/sbe/generated/
orders_response_codec.rs

1pub use decoder::OrdersResponseDecoder;
2pub use encoder::OrdersResponseEncoder;
3
4use super::*;
5pub use super::{SBE_SCHEMA_ID, SBE_SCHEMA_VERSION, SBE_SEMANTIC_VERSION};
6
7pub const SBE_BLOCK_LENGTH: u16 = 0;
8pub const SBE_TEMPLATE_ID: u16 = 308;
9
10pub mod encoder {
11    use message_header_codec::*;
12
13    use super::*;
14
15    #[derive(Debug, Default)]
16    pub struct OrdersResponseEncoder<'a> {
17        buf: WriteBuf<'a>,
18        initial_offset: usize,
19        offset: usize,
20        limit: usize,
21    }
22
23    impl<'a> Writer<'a> for OrdersResponseEncoder<'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 OrdersResponseEncoder<'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> OrdersResponseEncoder<'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        /// GROUP ENCODER (id=100)
67        #[inline]
68        pub fn orders_encoder(
69            self,
70            count: u32,
71            orders_encoder: OrdersEncoder<Self>,
72        ) -> OrdersEncoder<Self> {
73            orders_encoder.wrap(self, count)
74        }
75    }
76
77    #[derive(Debug, Default)]
78    pub struct OrdersEncoder<P> {
79        parent: Option<P>,
80        count: u32,
81        index: usize,
82        offset: usize,
83        initial_limit: usize,
84    }
85
86    impl<'a, P> Writer<'a> for OrdersEncoder<P>
87    where
88        P: Writer<'a> + Default,
89    {
90        #[inline]
91        fn get_buf_mut(&mut self) -> &mut WriteBuf<'a> {
92            if let Some(parent) = self.parent.as_mut() {
93                parent.get_buf_mut()
94            } else {
95                panic!("parent was None")
96            }
97        }
98    }
99
100    impl<'a, P> Encoder<'a> for OrdersEncoder<P>
101    where
102        P: Encoder<'a> + Default,
103    {
104        #[inline]
105        fn get_limit(&self) -> usize {
106            self.parent.as_ref().expect("parent missing").get_limit()
107        }
108
109        #[inline]
110        fn set_limit(&mut self, limit: usize) {
111            self.parent
112                .as_mut()
113                .expect("parent missing")
114                .set_limit(limit);
115        }
116    }
117
118    impl<'a, P> OrdersEncoder<P>
119    where
120        P: Encoder<'a> + Default,
121    {
122        #[inline]
123        pub fn wrap(mut self, mut parent: P, count: u32) -> Self {
124            let initial_limit = parent.get_limit();
125            parent.set_limit(initial_limit + 6);
126            parent
127                .get_buf_mut()
128                .put_u16_at(initial_limit, Self::block_length());
129            parent.get_buf_mut().put_u32_at(initial_limit + 2, count);
130            self.parent = Some(parent);
131            self.count = count;
132            self.index = usize::MAX;
133            self.offset = usize::MAX;
134            self.initial_limit = initial_limit;
135            self
136        }
137
138        #[inline]
139        pub fn block_length() -> u16 {
140            162
141        }
142
143        #[inline]
144        pub fn parent(&mut self) -> SbeResult<P> {
145            self.parent.take().ok_or(SbeErr::ParentNotSet)
146        }
147
148        /// will return Some(current index) when successful otherwise None
149        #[inline]
150        pub fn advance(&mut self) -> SbeResult<Option<usize>> {
151            let index = self.index.wrapping_add(1);
152            if index >= self.count as usize {
153                return Ok(None);
154            }
155
156            if let Some(parent) = self.parent.as_mut() {
157                self.offset = parent.get_limit();
158                parent.set_limit(self.offset + Self::block_length() as usize);
159                self.index = index;
160                Ok(Some(index))
161            } else {
162                Err(SbeErr::ParentNotSet)
163            }
164        }
165
166        /// primitive field 'priceExponent'
167        /// - min value: -127
168        /// - max value: 127
169        /// - null value: -128_i8
170        /// - characterEncoding: null
171        /// - semanticType: null
172        /// - encodedOffset: 0
173        /// - encodedLength: 1
174        /// - version: 0
175        #[inline]
176        pub fn price_exponent(&mut self, value: i8) {
177            let offset = self.offset;
178            self.get_buf_mut().put_i8_at(offset, value);
179        }
180
181        /// primitive field 'qtyExponent'
182        /// - min value: -127
183        /// - max value: 127
184        /// - null value: -128_i8
185        /// - characterEncoding: null
186        /// - semanticType: null
187        /// - encodedOffset: 1
188        /// - encodedLength: 1
189        /// - version: 0
190        #[inline]
191        pub fn qty_exponent(&mut self, value: i8) {
192            let offset = self.offset + 1;
193            self.get_buf_mut().put_i8_at(offset, value);
194        }
195
196        /// primitive field 'orderId'
197        /// - min value: -9223372036854775807
198        /// - max value: 9223372036854775807
199        /// - null value: -9223372036854775808_i64
200        /// - characterEncoding: null
201        /// - semanticType: null
202        /// - encodedOffset: 2
203        /// - encodedLength: 8
204        /// - version: 0
205        #[inline]
206        pub fn order_id(&mut self, value: i64) {
207            let offset = self.offset + 2;
208            self.get_buf_mut().put_i64_at(offset, value);
209        }
210
211        /// primitive field 'orderListId'
212        /// - min value: -9223372036854775807
213        /// - max value: 9223372036854775807
214        /// - null value: -9223372036854775808_i64
215        /// - characterEncoding: null
216        /// - semanticType: null
217        /// - encodedOffset: 10
218        /// - encodedLength: 8
219        /// - version: 0
220        #[inline]
221        pub fn order_list_id(&mut self, value: i64) {
222            let offset = self.offset + 10;
223            self.get_buf_mut().put_i64_at(offset, value);
224        }
225
226        /// primitive field 'price'
227        /// - min value: -9223372036854775807
228        /// - max value: 9223372036854775807
229        /// - null value: -9223372036854775808_i64
230        /// - characterEncoding: null
231        /// - semanticType: null
232        /// - encodedOffset: 18
233        /// - encodedLength: 8
234        /// - version: 0
235        #[inline]
236        pub fn price(&mut self, value: i64) {
237            let offset = self.offset + 18;
238            self.get_buf_mut().put_i64_at(offset, value);
239        }
240
241        /// primitive field 'origQty'
242        /// - min value: -9223372036854775807
243        /// - max value: 9223372036854775807
244        /// - null value: -9223372036854775808_i64
245        /// - characterEncoding: null
246        /// - semanticType: null
247        /// - encodedOffset: 26
248        /// - encodedLength: 8
249        /// - version: 0
250        #[inline]
251        pub fn orig_qty(&mut self, value: i64) {
252            let offset = self.offset + 26;
253            self.get_buf_mut().put_i64_at(offset, value);
254        }
255
256        /// primitive field 'executedQty'
257        /// - min value: -9223372036854775807
258        /// - max value: 9223372036854775807
259        /// - null value: -9223372036854775808_i64
260        /// - characterEncoding: null
261        /// - semanticType: null
262        /// - encodedOffset: 34
263        /// - encodedLength: 8
264        /// - version: 0
265        #[inline]
266        pub fn executed_qty(&mut self, value: i64) {
267            let offset = self.offset + 34;
268            self.get_buf_mut().put_i64_at(offset, value);
269        }
270
271        /// primitive field 'cummulativeQuoteQty'
272        /// - min value: -9223372036854775807
273        /// - max value: 9223372036854775807
274        /// - null value: -9223372036854775808_i64
275        /// - characterEncoding: null
276        /// - semanticType: null
277        /// - encodedOffset: 42
278        /// - encodedLength: 8
279        /// - version: 0
280        #[inline]
281        pub fn cummulative_quote_qty(&mut self, value: i64) {
282            let offset = self.offset + 42;
283            self.get_buf_mut().put_i64_at(offset, value);
284        }
285
286        /// REQUIRED enum
287        #[inline]
288        pub fn status(&mut self, value: order_status::OrderStatus) {
289            let offset = self.offset + 50;
290            self.get_buf_mut().put_u8_at(offset, value as u8)
291        }
292
293        /// REQUIRED enum
294        #[inline]
295        pub fn time_in_force(&mut self, value: time_in_force::TimeInForce) {
296            let offset = self.offset + 51;
297            self.get_buf_mut().put_u8_at(offset, value as u8)
298        }
299
300        /// REQUIRED enum
301        #[inline]
302        pub fn order_type(&mut self, value: order_type::OrderType) {
303            let offset = self.offset + 52;
304            self.get_buf_mut().put_u8_at(offset, value as u8)
305        }
306
307        /// REQUIRED enum
308        #[inline]
309        pub fn side(&mut self, value: order_side::OrderSide) {
310            let offset = self.offset + 53;
311            self.get_buf_mut().put_u8_at(offset, value as u8)
312        }
313
314        /// primitive field 'stopPrice'
315        /// - min value: -9223372036854775807
316        /// - max value: 9223372036854775807
317        /// - null value: -9223372036854775808_i64
318        /// - characterEncoding: null
319        /// - semanticType: null
320        /// - encodedOffset: 54
321        /// - encodedLength: 8
322        /// - version: 0
323        #[inline]
324        pub fn stop_price(&mut self, value: i64) {
325            let offset = self.offset + 54;
326            self.get_buf_mut().put_i64_at(offset, value);
327        }
328
329        /// primitive field 'trailingDelta'
330        /// - min value: -9223372036854775807
331        /// - max value: 9223372036854775807
332        /// - null value: -9223372036854775808_i64
333        /// - characterEncoding: null
334        /// - semanticType: null
335        /// - encodedOffset: 62
336        /// - encodedLength: 8
337        /// - version: 0
338        #[inline]
339        pub fn trailing_delta(&mut self, value: i64) {
340            let offset = self.offset + 62;
341            self.get_buf_mut().put_i64_at(offset, value);
342        }
343
344        /// primitive field 'trailingTime'
345        /// - min value: -9223372036854775807
346        /// - max value: 9223372036854775807
347        /// - null value: -9223372036854775808_i64
348        /// - characterEncoding: null
349        /// - semanticType: null
350        /// - encodedOffset: 70
351        /// - encodedLength: 8
352        /// - version: 0
353        #[inline]
354        pub fn trailing_time(&mut self, value: i64) {
355            let offset = self.offset + 70;
356            self.get_buf_mut().put_i64_at(offset, value);
357        }
358
359        /// primitive field 'icebergQty'
360        /// - min value: -9223372036854775807
361        /// - max value: 9223372036854775807
362        /// - null value: -9223372036854775808_i64
363        /// - characterEncoding: null
364        /// - semanticType: null
365        /// - encodedOffset: 78
366        /// - encodedLength: 8
367        /// - version: 0
368        #[inline]
369        pub fn iceberg_qty(&mut self, value: i64) {
370            let offset = self.offset + 78;
371            self.get_buf_mut().put_i64_at(offset, value);
372        }
373
374        /// primitive field 'time'
375        /// - min value: -9223372036854775807
376        /// - max value: 9223372036854775807
377        /// - null value: -9223372036854775808_i64
378        /// - characterEncoding: null
379        /// - semanticType: null
380        /// - encodedOffset: 86
381        /// - encodedLength: 8
382        /// - version: 0
383        #[inline]
384        pub fn time(&mut self, value: i64) {
385            let offset = self.offset + 86;
386            self.get_buf_mut().put_i64_at(offset, value);
387        }
388
389        /// primitive field 'updateTime'
390        /// - min value: -9223372036854775807
391        /// - max value: 9223372036854775807
392        /// - null value: -9223372036854775808_i64
393        /// - characterEncoding: null
394        /// - semanticType: null
395        /// - encodedOffset: 94
396        /// - encodedLength: 8
397        /// - version: 0
398        #[inline]
399        pub fn update_time(&mut self, value: i64) {
400            let offset = self.offset + 94;
401            self.get_buf_mut().put_i64_at(offset, value);
402        }
403
404        /// REQUIRED enum
405        #[inline]
406        pub fn is_working(&mut self, value: bool_enum::BoolEnum) {
407            let offset = self.offset + 102;
408            self.get_buf_mut().put_u8_at(offset, value as u8)
409        }
410
411        /// primitive field 'workingTime'
412        /// - min value: -9223372036854775807
413        /// - max value: 9223372036854775807
414        /// - null value: -9223372036854775808_i64
415        /// - characterEncoding: null
416        /// - semanticType: null
417        /// - encodedOffset: 103
418        /// - encodedLength: 8
419        /// - version: 0
420        #[inline]
421        pub fn working_time(&mut self, value: i64) {
422            let offset = self.offset + 103;
423            self.get_buf_mut().put_i64_at(offset, value);
424        }
425
426        /// primitive field 'origQuoteOrderQty'
427        /// - min value: -9223372036854775807
428        /// - max value: 9223372036854775807
429        /// - null value: -9223372036854775808_i64
430        /// - characterEncoding: null
431        /// - semanticType: null
432        /// - encodedOffset: 111
433        /// - encodedLength: 8
434        /// - version: 0
435        #[inline]
436        pub fn orig_quote_order_qty(&mut self, value: i64) {
437            let offset = self.offset + 111;
438            self.get_buf_mut().put_i64_at(offset, value);
439        }
440
441        /// primitive field 'strategyId'
442        /// - min value: -9223372036854775807
443        /// - max value: 9223372036854775807
444        /// - null value: -9223372036854775808_i64
445        /// - characterEncoding: null
446        /// - semanticType: null
447        /// - encodedOffset: 119
448        /// - encodedLength: 8
449        /// - version: 0
450        #[inline]
451        pub fn strategy_id(&mut self, value: i64) {
452            let offset = self.offset + 119;
453            self.get_buf_mut().put_i64_at(offset, value);
454        }
455
456        /// primitive field 'strategyType'
457        /// - min value: -2147483647
458        /// - max value: 2147483647
459        /// - null value: -2147483648_i32
460        /// - characterEncoding: null
461        /// - semanticType: null
462        /// - encodedOffset: 127
463        /// - encodedLength: 4
464        /// - version: 0
465        #[inline]
466        pub fn strategy_type(&mut self, value: i32) {
467            let offset = self.offset + 127;
468            self.get_buf_mut().put_i32_at(offset, value);
469        }
470
471        /// REQUIRED enum
472        #[inline]
473        pub fn order_capacity(&mut self, value: order_capacity::OrderCapacity) {
474            let offset = self.offset + 131;
475            self.get_buf_mut().put_u8_at(offset, value as u8)
476        }
477
478        /// REQUIRED enum
479        #[inline]
480        pub fn working_floor(&mut self, value: floor::Floor) {
481            let offset = self.offset + 132;
482            self.get_buf_mut().put_u8_at(offset, value as u8)
483        }
484
485        /// REQUIRED enum
486        #[inline]
487        pub fn self_trade_prevention_mode(
488            &mut self,
489            value: self_trade_prevention_mode::SelfTradePreventionMode,
490        ) {
491            let offset = self.offset + 133;
492            self.get_buf_mut().put_u8_at(offset, value as u8)
493        }
494
495        /// primitive field 'preventedMatchId'
496        /// - min value: -9223372036854775807
497        /// - max value: 9223372036854775807
498        /// - null value: -9223372036854775808_i64
499        /// - characterEncoding: null
500        /// - semanticType: null
501        /// - encodedOffset: 134
502        /// - encodedLength: 8
503        /// - version: 0
504        #[inline]
505        pub fn prevented_match_id(&mut self, value: i64) {
506            let offset = self.offset + 134;
507            self.get_buf_mut().put_i64_at(offset, value);
508        }
509
510        /// primitive field 'preventedQuantity'
511        /// - min value: -9223372036854775807
512        /// - max value: 9223372036854775807
513        /// - null value: -9223372036854775808_i64
514        /// - characterEncoding: null
515        /// - semanticType: null
516        /// - encodedOffset: 142
517        /// - encodedLength: 8
518        /// - version: 0
519        #[inline]
520        pub fn prevented_quantity(&mut self, value: i64) {
521            let offset = self.offset + 142;
522            self.get_buf_mut().put_i64_at(offset, value);
523        }
524
525        /// REQUIRED enum
526        #[inline]
527        pub fn used_sor(&mut self, value: bool_enum::BoolEnum) {
528            let offset = self.offset + 150;
529            self.get_buf_mut().put_u8_at(offset, value as u8)
530        }
531
532        /// REQUIRED enum
533        #[inline]
534        pub fn peg_price_type(&mut self, value: peg_price_type::PegPriceType) {
535            let offset = self.offset + 151;
536            self.get_buf_mut().put_u8_at(offset, value as u8)
537        }
538
539        /// REQUIRED enum
540        #[inline]
541        pub fn peg_offset_type(&mut self, value: peg_offset_type::PegOffsetType) {
542            let offset = self.offset + 152;
543            self.get_buf_mut().put_u8_at(offset, value as u8)
544        }
545
546        /// primitive field 'pegOffsetValue'
547        /// - min value: 0
548        /// - max value: 254
549        /// - null value: 0xff_u8
550        /// - characterEncoding: null
551        /// - semanticType: null
552        /// - encodedOffset: 153
553        /// - encodedLength: 1
554        /// - version: 1
555        #[inline]
556        pub fn peg_offset_value(&mut self, value: u8) {
557            let offset = self.offset + 153;
558            self.get_buf_mut().put_u8_at(offset, value);
559        }
560
561        /// primitive field 'peggedPrice'
562        /// - min value: -9223372036854775807
563        /// - max value: 9223372036854775807
564        /// - null value: -9223372036854775808_i64
565        /// - characterEncoding: null
566        /// - semanticType: null
567        /// - encodedOffset: 154
568        /// - encodedLength: 8
569        /// - version: 1
570        #[inline]
571        pub fn pegged_price(&mut self, value: i64) {
572            let offset = self.offset + 154;
573            self.get_buf_mut().put_i64_at(offset, value);
574        }
575
576        /// VAR_DATA ENCODER - character encoding: 'UTF-8'
577        #[inline]
578        pub fn symbol(&mut self, value: &str) {
579            let limit = self.get_limit();
580            let data_length = value.len();
581            self.set_limit(limit + 1 + data_length);
582            self.get_buf_mut().put_u8_at(limit, data_length as u8);
583            self.get_buf_mut().put_slice_at(limit + 1, value.as_bytes());
584        }
585
586        /// VAR_DATA ENCODER - character encoding: 'UTF-8'
587        #[inline]
588        pub fn client_order_id(&mut self, value: &str) {
589            let limit = self.get_limit();
590            let data_length = value.len();
591            self.set_limit(limit + 1 + data_length);
592            self.get_buf_mut().put_u8_at(limit, data_length as u8);
593            self.get_buf_mut().put_slice_at(limit + 1, value.as_bytes());
594        }
595    }
596} // end encoder
597
598pub mod decoder {
599    use message_header_codec::*;
600
601    use super::*;
602
603    #[derive(Clone, Copy, Debug, Default)]
604    pub struct OrdersResponseDecoder<'a> {
605        buf: ReadBuf<'a>,
606        initial_offset: usize,
607        offset: usize,
608        limit: usize,
609        pub acting_block_length: u16,
610        pub acting_version: u16,
611    }
612
613    impl ActingVersion for OrdersResponseDecoder<'_> {
614        #[inline]
615        fn acting_version(&self) -> u16 {
616            self.acting_version
617        }
618    }
619
620    impl<'a> Reader<'a> for OrdersResponseDecoder<'a> {
621        #[inline]
622        fn get_buf(&self) -> &ReadBuf<'a> {
623            &self.buf
624        }
625    }
626
627    impl<'a> Decoder<'a> for OrdersResponseDecoder<'a> {
628        #[inline]
629        fn get_limit(&self) -> usize {
630            self.limit
631        }
632
633        #[inline]
634        fn set_limit(&mut self, limit: usize) {
635            self.limit = limit;
636        }
637    }
638
639    impl<'a> OrdersResponseDecoder<'a> {
640        pub fn wrap(
641            mut self,
642            buf: ReadBuf<'a>,
643            offset: usize,
644            acting_block_length: u16,
645            acting_version: u16,
646        ) -> Self {
647            let limit = offset + acting_block_length as usize;
648            self.buf = buf;
649            self.initial_offset = offset;
650            self.offset = offset;
651            self.limit = limit;
652            self.acting_block_length = acting_block_length;
653            self.acting_version = acting_version;
654            self
655        }
656
657        #[inline]
658        pub fn encoded_length(&self) -> usize {
659            self.limit - self.offset
660        }
661
662        pub fn header(self, mut header: MessageHeaderDecoder<ReadBuf<'a>>, offset: usize) -> Self {
663            debug_assert_eq!(SBE_TEMPLATE_ID, header.template_id());
664            let acting_block_length = header.block_length();
665            let acting_version = header.version();
666
667            self.wrap(
668                header.parent().unwrap(),
669                offset + message_header_codec::ENCODED_LENGTH,
670                acting_block_length,
671                acting_version,
672            )
673        }
674
675        /// GROUP DECODER (id=100)
676        #[inline]
677        pub fn orders_decoder(self) -> OrdersDecoder<Self> {
678            OrdersDecoder::default().wrap(self)
679        }
680    }
681
682    #[derive(Debug, Default)]
683    pub struct OrdersDecoder<P> {
684        parent: Option<P>,
685        block_length: u16,
686        count: u32,
687        index: usize,
688        offset: usize,
689    }
690
691    impl<'a, P> ActingVersion for OrdersDecoder<P>
692    where
693        P: Reader<'a> + ActingVersion + Default,
694    {
695        #[inline]
696        fn acting_version(&self) -> u16 {
697            self.parent.as_ref().unwrap().acting_version()
698        }
699    }
700
701    impl<'a, P> Reader<'a> for OrdersDecoder<P>
702    where
703        P: Reader<'a> + Default,
704    {
705        #[inline]
706        fn get_buf(&self) -> &ReadBuf<'a> {
707            self.parent.as_ref().expect("parent missing").get_buf()
708        }
709    }
710
711    impl<'a, P> Decoder<'a> for OrdersDecoder<P>
712    where
713        P: Decoder<'a> + ActingVersion + Default,
714    {
715        #[inline]
716        fn get_limit(&self) -> usize {
717            self.parent.as_ref().expect("parent missing").get_limit()
718        }
719
720        #[inline]
721        fn set_limit(&mut self, limit: usize) {
722            self.parent
723                .as_mut()
724                .expect("parent missing")
725                .set_limit(limit);
726        }
727    }
728
729    impl<'a, P> OrdersDecoder<P>
730    where
731        P: Decoder<'a> + ActingVersion + Default,
732    {
733        pub fn wrap(mut self, mut parent: P) -> Self {
734            let initial_offset = parent.get_limit();
735            let block_length = parent.get_buf().get_u16_at(initial_offset);
736            let count = parent.get_buf().get_u32_at(initial_offset + 2);
737            parent.set_limit(initial_offset + 6);
738            self.parent = Some(parent);
739            self.block_length = block_length;
740            self.count = count;
741            self.index = usize::MAX;
742            self.offset = 0;
743            self
744        }
745
746        /// group token - Token{signal=BEGIN_GROUP, name='orders', referencedName='null', description='null', packageName='null', id=100, version=0, deprecated=0, encodedLength=162, offset=0, componentTokenCount=177, 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'}}
747        #[inline]
748        pub fn parent(&mut self) -> SbeResult<P> {
749            self.parent.take().ok_or(SbeErr::ParentNotSet)
750        }
751
752        #[inline]
753        pub fn acting_version(&mut self) -> u16 {
754            self.parent.as_ref().unwrap().acting_version()
755        }
756
757        #[inline]
758        pub fn count(&self) -> u32 {
759            self.count
760        }
761
762        /// will return Some(current index) when successful otherwise None
763        pub fn advance(&mut self) -> SbeResult<Option<usize>> {
764            let index = self.index.wrapping_add(1);
765            if index >= self.count as usize {
766                return Ok(None);
767            }
768
769            if let Some(parent) = self.parent.as_mut() {
770                self.offset = parent.get_limit();
771                parent.set_limit(self.offset + self.block_length as usize);
772                self.index = index;
773                Ok(Some(index))
774            } else {
775                Err(SbeErr::ParentNotSet)
776            }
777        }
778
779        /// primitive field - 'REQUIRED'
780        #[inline]
781        pub fn price_exponent(&self) -> i8 {
782            self.get_buf().get_i8_at(self.offset)
783        }
784
785        /// primitive field - 'REQUIRED'
786        #[inline]
787        pub fn qty_exponent(&self) -> i8 {
788            self.get_buf().get_i8_at(self.offset + 1)
789        }
790
791        /// primitive field - 'REQUIRED'
792        #[inline]
793        pub fn order_id(&self) -> i64 {
794            self.get_buf().get_i64_at(self.offset + 2)
795        }
796
797        /// primitive field - 'OPTIONAL' { null_value: '-9223372036854775808_i64' }
798        #[inline]
799        pub fn order_list_id(&self) -> Option<i64> {
800            let value = self.get_buf().get_i64_at(self.offset + 10);
801            if value == -9223372036854775808_i64 {
802                None
803            } else {
804                Some(value)
805            }
806        }
807
808        /// primitive field - 'REQUIRED'
809        #[inline]
810        pub fn price(&self) -> i64 {
811            self.get_buf().get_i64_at(self.offset + 18)
812        }
813
814        /// primitive field - 'REQUIRED'
815        #[inline]
816        pub fn orig_qty(&self) -> i64 {
817            self.get_buf().get_i64_at(self.offset + 26)
818        }
819
820        /// primitive field - 'REQUIRED'
821        #[inline]
822        pub fn executed_qty(&self) -> i64 {
823            self.get_buf().get_i64_at(self.offset + 34)
824        }
825
826        /// primitive field - 'REQUIRED'
827        #[inline]
828        pub fn cummulative_quote_qty(&self) -> i64 {
829            self.get_buf().get_i64_at(self.offset + 42)
830        }
831
832        /// REQUIRED enum
833        #[inline]
834        pub fn status(&self) -> order_status::OrderStatus {
835            self.get_buf().get_u8_at(self.offset + 50).into()
836        }
837
838        /// REQUIRED enum
839        #[inline]
840        pub fn time_in_force(&self) -> time_in_force::TimeInForce {
841            self.get_buf().get_u8_at(self.offset + 51).into()
842        }
843
844        /// REQUIRED enum
845        #[inline]
846        pub fn order_type(&self) -> order_type::OrderType {
847            self.get_buf().get_u8_at(self.offset + 52).into()
848        }
849
850        /// REQUIRED enum
851        #[inline]
852        pub fn side(&self) -> order_side::OrderSide {
853            self.get_buf().get_u8_at(self.offset + 53).into()
854        }
855
856        /// primitive field - 'OPTIONAL' { null_value: '-9223372036854775808_i64' }
857        #[inline]
858        pub fn stop_price(&self) -> Option<i64> {
859            let value = self.get_buf().get_i64_at(self.offset + 54);
860            if value == -9223372036854775808_i64 {
861                None
862            } else {
863                Some(value)
864            }
865        }
866
867        /// primitive field - 'OPTIONAL' { null_value: '-9223372036854775808_i64' }
868        #[inline]
869        pub fn trailing_delta(&self) -> Option<i64> {
870            let value = self.get_buf().get_i64_at(self.offset + 62);
871            if value == -9223372036854775808_i64 {
872                None
873            } else {
874                Some(value)
875            }
876        }
877
878        /// primitive field - 'OPTIONAL' { null_value: '-9223372036854775808_i64' }
879        #[inline]
880        pub fn trailing_time(&self) -> Option<i64> {
881            let value = self.get_buf().get_i64_at(self.offset + 70);
882            if value == -9223372036854775808_i64 {
883                None
884            } else {
885                Some(value)
886            }
887        }
888
889        /// primitive field - 'OPTIONAL' { null_value: '-9223372036854775808_i64' }
890        #[inline]
891        pub fn iceberg_qty(&self) -> Option<i64> {
892            let value = self.get_buf().get_i64_at(self.offset + 78);
893            if value == -9223372036854775808_i64 {
894                None
895            } else {
896                Some(value)
897            }
898        }
899
900        /// primitive field - 'REQUIRED'
901        #[inline]
902        pub fn time(&self) -> i64 {
903            self.get_buf().get_i64_at(self.offset + 86)
904        }
905
906        /// primitive field - 'REQUIRED'
907        #[inline]
908        pub fn update_time(&self) -> i64 {
909            self.get_buf().get_i64_at(self.offset + 94)
910        }
911
912        /// REQUIRED enum
913        #[inline]
914        pub fn is_working(&self) -> bool_enum::BoolEnum {
915            self.get_buf().get_u8_at(self.offset + 102).into()
916        }
917
918        /// primitive field - 'OPTIONAL' { null_value: '-9223372036854775808_i64' }
919        #[inline]
920        pub fn working_time(&self) -> Option<i64> {
921            let value = self.get_buf().get_i64_at(self.offset + 103);
922            if value == -9223372036854775808_i64 {
923                None
924            } else {
925                Some(value)
926            }
927        }
928
929        /// primitive field - 'REQUIRED'
930        #[inline]
931        pub fn orig_quote_order_qty(&self) -> i64 {
932            self.get_buf().get_i64_at(self.offset + 111)
933        }
934
935        /// primitive field - 'OPTIONAL' { null_value: '-9223372036854775808_i64' }
936        #[inline]
937        pub fn strategy_id(&self) -> Option<i64> {
938            let value = self.get_buf().get_i64_at(self.offset + 119);
939            if value == -9223372036854775808_i64 {
940                None
941            } else {
942                Some(value)
943            }
944        }
945
946        /// primitive field - 'OPTIONAL' { null_value: '-2147483648_i32' }
947        #[inline]
948        pub fn strategy_type(&self) -> Option<i32> {
949            let value = self.get_buf().get_i32_at(self.offset + 127);
950            if value == -2147483648_i32 {
951                None
952            } else {
953                Some(value)
954            }
955        }
956
957        /// REQUIRED enum
958        #[inline]
959        pub fn order_capacity(&self) -> order_capacity::OrderCapacity {
960            self.get_buf().get_u8_at(self.offset + 131).into()
961        }
962
963        /// REQUIRED enum
964        #[inline]
965        pub fn working_floor(&self) -> floor::Floor {
966            self.get_buf().get_u8_at(self.offset + 132).into()
967        }
968
969        /// REQUIRED enum
970        #[inline]
971        pub fn self_trade_prevention_mode(
972            &self,
973        ) -> self_trade_prevention_mode::SelfTradePreventionMode {
974            self.get_buf().get_u8_at(self.offset + 133).into()
975        }
976
977        /// primitive field - 'OPTIONAL' { null_value: '-9223372036854775808_i64' }
978        #[inline]
979        pub fn prevented_match_id(&self) -> Option<i64> {
980            let value = self.get_buf().get_i64_at(self.offset + 134);
981            if value == -9223372036854775808_i64 {
982                None
983            } else {
984                Some(value)
985            }
986        }
987
988        /// primitive field - 'REQUIRED'
989        #[inline]
990        pub fn prevented_quantity(&self) -> i64 {
991            self.get_buf().get_i64_at(self.offset + 142)
992        }
993
994        /// REQUIRED enum
995        #[inline]
996        pub fn used_sor(&self) -> bool_enum::BoolEnum {
997            self.get_buf().get_u8_at(self.offset + 150).into()
998        }
999
1000        /// REQUIRED enum
1001        #[inline]
1002        pub fn peg_price_type(&self) -> peg_price_type::PegPriceType {
1003            if self.acting_version() < 1 {
1004                return peg_price_type::PegPriceType::default();
1005            }
1006
1007            self.get_buf().get_u8_at(self.offset + 151).into()
1008        }
1009
1010        /// REQUIRED enum
1011        #[inline]
1012        pub fn peg_offset_type(&self) -> peg_offset_type::PegOffsetType {
1013            if self.acting_version() < 1 {
1014                return peg_offset_type::PegOffsetType::default();
1015            }
1016
1017            self.get_buf().get_u8_at(self.offset + 152).into()
1018        }
1019
1020        /// primitive field - 'OPTIONAL' { null_value: '0xff_u8' }
1021        #[inline]
1022        pub fn peg_offset_value(&self) -> Option<u8> {
1023            if self.acting_version() < 1 {
1024                return None;
1025            }
1026
1027            let value = self.get_buf().get_u8_at(self.offset + 153);
1028            if value == 0xff_u8 { None } else { Some(value) }
1029        }
1030
1031        /// primitive field - 'OPTIONAL' { null_value: '-9223372036854775808_i64' }
1032        #[inline]
1033        pub fn pegged_price(&self) -> Option<i64> {
1034            if self.acting_version() < 1 {
1035                return None;
1036            }
1037
1038            let value = self.get_buf().get_i64_at(self.offset + 154);
1039            if value == -9223372036854775808_i64 {
1040                None
1041            } else {
1042                Some(value)
1043            }
1044        }
1045
1046        /// VAR_DATA DECODER - character encoding: 'UTF-8'
1047        #[inline]
1048        pub fn symbol_decoder(&mut self) -> (usize, usize) {
1049            let offset = self.parent.as_ref().expect("parent missing").get_limit();
1050            let data_length = self.get_buf().get_u8_at(offset) as usize;
1051            self.parent
1052                .as_mut()
1053                .unwrap()
1054                .set_limit(offset + 1 + data_length);
1055            (offset + 1, data_length)
1056        }
1057
1058        #[inline]
1059        pub fn symbol_slice(&'a self, coordinates: (usize, usize)) -> &'a [u8] {
1060            debug_assert!(self.get_limit() >= coordinates.0 + coordinates.1);
1061            self.get_buf().get_slice_at(coordinates.0, coordinates.1)
1062        }
1063
1064        /// VAR_DATA DECODER - character encoding: 'UTF-8'
1065        #[inline]
1066        pub fn client_order_id_decoder(&mut self) -> (usize, usize) {
1067            let offset = self.parent.as_ref().expect("parent missing").get_limit();
1068            let data_length = self.get_buf().get_u8_at(offset) as usize;
1069            self.parent
1070                .as_mut()
1071                .unwrap()
1072                .set_limit(offset + 1 + data_length);
1073            (offset + 1, data_length)
1074        }
1075
1076        #[inline]
1077        pub fn client_order_id_slice(&'a self, coordinates: (usize, usize)) -> &'a [u8] {
1078            debug_assert!(self.get_limit() >= coordinates.0 + coordinates.1);
1079            self.get_buf().get_slice_at(coordinates.0, coordinates.1)
1080        }
1081    }
1082} // end decoder