1pub use decoder::NewOrderFullResponseDecoder;
2pub use encoder::NewOrderFullResponseEncoder;
3
4use super::*;
5pub use super::{SBE_SCHEMA_ID, SBE_SCHEMA_VERSION, SBE_SEMANTIC_VERSION};
6
7pub const SBE_BLOCK_LENGTH: u16 = 154;
8pub const SBE_TEMPLATE_ID: u16 = 302;
9
10pub mod encoder {
11 use message_header_codec::*;
12
13 use super::*;
14
15 #[derive(Debug, Default)]
16 pub struct NewOrderFullResponseEncoder<'a> {
17 buf: WriteBuf<'a>,
18 initial_offset: usize,
19 offset: usize,
20 limit: usize,
21 }
22
23 impl<'a> Writer<'a> for NewOrderFullResponseEncoder<'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 NewOrderFullResponseEncoder<'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> NewOrderFullResponseEncoder<'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 price_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 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 #[inline]
106 pub fn order_id(&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 order_list_id(&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 transact_time(&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 price(&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 orig_qty(&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 executed_qty(&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 cummulative_quote_qty(&mut self, value: i64) {
197 let offset = self.offset + 50;
198 self.get_buf_mut().put_i64_at(offset, value);
199 }
200
201 #[inline]
203 pub fn status(&mut self, value: order_status::OrderStatus) {
204 let offset = self.offset + 58;
205 self.get_buf_mut().put_u8_at(offset, value as u8)
206 }
207
208 #[inline]
210 pub fn time_in_force(&mut self, value: time_in_force::TimeInForce) {
211 let offset = self.offset + 59;
212 self.get_buf_mut().put_u8_at(offset, value as u8)
213 }
214
215 #[inline]
217 pub fn order_type(&mut self, value: order_type::OrderType) {
218 let offset = self.offset + 60;
219 self.get_buf_mut().put_u8_at(offset, value as u8)
220 }
221
222 #[inline]
224 pub fn side(&mut self, value: order_side::OrderSide) {
225 let offset = self.offset + 61;
226 self.get_buf_mut().put_u8_at(offset, value as u8)
227 }
228
229 #[inline]
239 pub fn stop_price(&mut self, value: i64) {
240 let offset = self.offset + 62;
241 self.get_buf_mut().put_i64_at(offset, value);
242 }
243
244 #[inline]
254 pub fn trailing_delta(&mut self, value: i64) {
255 let offset = self.offset + 70;
256 self.get_buf_mut().put_i64_at(offset, value);
257 }
258
259 #[inline]
269 pub fn trailing_time(&mut self, value: i64) {
270 let offset = self.offset + 78;
271 self.get_buf_mut().put_i64_at(offset, value);
272 }
273
274 #[inline]
284 pub fn working_time(&mut self, value: i64) {
285 let offset = self.offset + 86;
286 self.get_buf_mut().put_i64_at(offset, value);
287 }
288
289 #[inline]
299 pub fn iceberg_qty(&mut self, value: i64) {
300 let offset = self.offset + 94;
301 self.get_buf_mut().put_i64_at(offset, value);
302 }
303
304 #[inline]
314 pub fn strategy_id(&mut self, value: i64) {
315 let offset = self.offset + 102;
316 self.get_buf_mut().put_i64_at(offset, value);
317 }
318
319 #[inline]
329 pub fn strategy_type(&mut self, value: i32) {
330 let offset = self.offset + 110;
331 self.get_buf_mut().put_i32_at(offset, value);
332 }
333
334 #[inline]
336 pub fn order_capacity(&mut self, value: order_capacity::OrderCapacity) {
337 let offset = self.offset + 114;
338 self.get_buf_mut().put_u8_at(offset, value as u8)
339 }
340
341 #[inline]
343 pub fn working_floor(&mut self, value: floor::Floor) {
344 let offset = self.offset + 115;
345 self.get_buf_mut().put_u8_at(offset, value as u8)
346 }
347
348 #[inline]
350 pub fn self_trade_prevention_mode(
351 &mut self,
352 value: self_trade_prevention_mode::SelfTradePreventionMode,
353 ) {
354 let offset = self.offset + 116;
355 self.get_buf_mut().put_u8_at(offset, value as u8)
356 }
357
358 #[inline]
368 pub fn trade_group_id(&mut self, value: i64) {
369 let offset = self.offset + 117;
370 self.get_buf_mut().put_i64_at(offset, value);
371 }
372
373 #[inline]
383 pub fn prevented_quantity(&mut self, value: i64) {
384 let offset = self.offset + 125;
385 self.get_buf_mut().put_i64_at(offset, value);
386 }
387
388 #[inline]
390 pub fn used_sor(&mut self, value: bool_enum::BoolEnum) {
391 let offset = self.offset + 133;
392 self.get_buf_mut().put_u8_at(offset, value as u8)
393 }
394
395 #[inline]
405 pub fn orig_quote_order_qty(&mut self, value: i64) {
406 let offset = self.offset + 134;
407 self.get_buf_mut().put_i64_at(offset, value);
408 }
409
410 #[inline]
412 pub fn peg_price_type(&mut self, value: peg_price_type::PegPriceType) {
413 let offset = self.offset + 142;
414 self.get_buf_mut().put_u8_at(offset, value as u8)
415 }
416
417 #[inline]
419 pub fn peg_offset_type(&mut self, value: peg_offset_type::PegOffsetType) {
420 let offset = self.offset + 143;
421 self.get_buf_mut().put_u8_at(offset, value as u8)
422 }
423
424 #[inline]
434 pub fn peg_offset_value(&mut self, value: u8) {
435 let offset = self.offset + 144;
436 self.get_buf_mut().put_u8_at(offset, value);
437 }
438
439 #[inline]
449 pub fn pegged_price(&mut self, value: i64) {
450 let offset = self.offset + 145;
451 self.get_buf_mut().put_i64_at(offset, value);
452 }
453
454 #[inline]
456 pub fn expiry_reason(&mut self, value: expiry_reason::ExpiryReason) {
457 let offset = self.offset + 153;
458 self.get_buf_mut().put_u8_at(offset, value as u8)
459 }
460
461 #[inline]
463 pub fn fills_encoder(
464 self,
465 count: u32,
466 fills_encoder: FillsEncoder<Self>,
467 ) -> FillsEncoder<Self> {
468 fills_encoder.wrap(self, count)
469 }
470
471 #[inline]
473 pub fn prevented_matches_encoder(
474 self,
475 count: u32,
476 prevented_matches_encoder: PreventedMatchesEncoder<Self>,
477 ) -> PreventedMatchesEncoder<Self> {
478 prevented_matches_encoder.wrap(self, count)
479 }
480
481 #[inline]
483 pub fn symbol(&mut self, value: &str) {
484 let limit = self.get_limit();
485 let data_length = value.len();
486 self.set_limit(limit + 1 + data_length);
487 self.get_buf_mut().put_u8_at(limit, data_length as u8);
488 self.get_buf_mut().put_slice_at(limit + 1, value.as_bytes());
489 }
490
491 #[inline]
493 pub fn client_order_id(&mut self, value: &str) {
494 let limit = self.get_limit();
495 let data_length = value.len();
496 self.set_limit(limit + 1 + data_length);
497 self.get_buf_mut().put_u8_at(limit, data_length as u8);
498 self.get_buf_mut().put_slice_at(limit + 1, value.as_bytes());
499 }
500 }
501
502 #[derive(Debug, Default)]
503 pub struct FillsEncoder<P> {
504 parent: Option<P>,
505 count: u32,
506 index: usize,
507 offset: usize,
508 initial_limit: usize,
509 }
510
511 impl<'a, P> Writer<'a> for FillsEncoder<P>
512 where
513 P: Writer<'a> + Default,
514 {
515 #[inline]
516 fn get_buf_mut(&mut self) -> &mut WriteBuf<'a> {
517 if let Some(parent) = self.parent.as_mut() {
518 parent.get_buf_mut()
519 } else {
520 panic!("parent was None")
521 }
522 }
523 }
524
525 impl<'a, P> Encoder<'a> for FillsEncoder<P>
526 where
527 P: Encoder<'a> + Default,
528 {
529 #[inline]
530 fn get_limit(&self) -> usize {
531 self.parent.as_ref().expect("parent missing").get_limit()
532 }
533
534 #[inline]
535 fn set_limit(&mut self, limit: usize) {
536 self.parent
537 .as_mut()
538 .expect("parent missing")
539 .set_limit(limit);
540 }
541 }
542
543 impl<'a, P> FillsEncoder<P>
544 where
545 P: Encoder<'a> + Default,
546 {
547 #[inline]
548 pub fn wrap(mut self, mut parent: P, count: u32) -> Self {
549 let initial_limit = parent.get_limit();
550 parent.set_limit(initial_limit + 6);
551 parent
552 .get_buf_mut()
553 .put_u16_at(initial_limit, Self::block_length());
554 parent.get_buf_mut().put_u32_at(initial_limit + 2, count);
555 self.parent = Some(parent);
556 self.count = count;
557 self.index = usize::MAX;
558 self.offset = usize::MAX;
559 self.initial_limit = initial_limit;
560 self
561 }
562
563 #[inline]
564 pub fn block_length() -> u16 {
565 42
566 }
567
568 #[inline]
569 pub fn parent(&mut self) -> SbeResult<P> {
570 self.parent.take().ok_or(SbeErr::ParentNotSet)
571 }
572
573 #[inline]
575 pub fn advance(&mut self) -> SbeResult<Option<usize>> {
576 let index = self.index.wrapping_add(1);
577 if index >= self.count as usize {
578 return Ok(None);
579 }
580
581 if let Some(parent) = self.parent.as_mut() {
582 self.offset = parent.get_limit();
583 parent.set_limit(self.offset + Self::block_length() as usize);
584 self.index = index;
585 Ok(Some(index))
586 } else {
587 Err(SbeErr::ParentNotSet)
588 }
589 }
590
591 #[inline]
601 pub fn commission_exponent(&mut self, value: i8) {
602 let offset = self.offset;
603 self.get_buf_mut().put_i8_at(offset, value);
604 }
605
606 #[inline]
608 pub fn match_type(&mut self, value: match_type::MatchType) {
609 let offset = self.offset + 1;
610 self.get_buf_mut().put_u8_at(offset, value as u8)
611 }
612
613 #[inline]
623 pub fn price(&mut self, value: i64) {
624 let offset = self.offset + 2;
625 self.get_buf_mut().put_i64_at(offset, value);
626 }
627
628 #[inline]
638 pub fn qty(&mut self, value: i64) {
639 let offset = self.offset + 10;
640 self.get_buf_mut().put_i64_at(offset, value);
641 }
642
643 #[inline]
653 pub fn commission(&mut self, value: i64) {
654 let offset = self.offset + 18;
655 self.get_buf_mut().put_i64_at(offset, value);
656 }
657
658 #[inline]
668 pub fn trade_id(&mut self, value: i64) {
669 let offset = self.offset + 26;
670 self.get_buf_mut().put_i64_at(offset, value);
671 }
672
673 #[inline]
683 pub fn alloc_id(&mut self, value: i64) {
684 let offset = self.offset + 34;
685 self.get_buf_mut().put_i64_at(offset, value);
686 }
687
688 #[inline]
690 pub fn commission_asset(&mut self, value: &str) {
691 let limit = self.get_limit();
692 let data_length = value.len();
693 self.set_limit(limit + 1 + data_length);
694 self.get_buf_mut().put_u8_at(limit, data_length as u8);
695 self.get_buf_mut().put_slice_at(limit + 1, value.as_bytes());
696 }
697 }
698
699 #[derive(Debug, Default)]
700 pub struct PreventedMatchesEncoder<P> {
701 parent: Option<P>,
702 count: u32,
703 index: usize,
704 offset: usize,
705 initial_limit: usize,
706 }
707
708 impl<'a, P> Writer<'a> for PreventedMatchesEncoder<P>
709 where
710 P: Writer<'a> + Default,
711 {
712 #[inline]
713 fn get_buf_mut(&mut self) -> &mut WriteBuf<'a> {
714 if let Some(parent) = self.parent.as_mut() {
715 parent.get_buf_mut()
716 } else {
717 panic!("parent was None")
718 }
719 }
720 }
721
722 impl<'a, P> Encoder<'a> for PreventedMatchesEncoder<P>
723 where
724 P: Encoder<'a> + Default,
725 {
726 #[inline]
727 fn get_limit(&self) -> usize {
728 self.parent.as_ref().expect("parent missing").get_limit()
729 }
730
731 #[inline]
732 fn set_limit(&mut self, limit: usize) {
733 self.parent
734 .as_mut()
735 .expect("parent missing")
736 .set_limit(limit);
737 }
738 }
739
740 impl<'a, P> PreventedMatchesEncoder<P>
741 where
742 P: Encoder<'a> + Default,
743 {
744 #[inline]
745 pub fn wrap(mut self, mut parent: P, count: u32) -> Self {
746 let initial_limit = parent.get_limit();
747 parent.set_limit(initial_limit + 6);
748 parent
749 .get_buf_mut()
750 .put_u16_at(initial_limit, Self::block_length());
751 parent.get_buf_mut().put_u32_at(initial_limit + 2, count);
752 self.parent = Some(parent);
753 self.count = count;
754 self.index = usize::MAX;
755 self.offset = usize::MAX;
756 self.initial_limit = initial_limit;
757 self
758 }
759
760 #[inline]
761 pub fn block_length() -> u16 {
762 40
763 }
764
765 #[inline]
766 pub fn parent(&mut self) -> SbeResult<P> {
767 self.parent.take().ok_or(SbeErr::ParentNotSet)
768 }
769
770 #[inline]
772 pub fn advance(&mut self) -> SbeResult<Option<usize>> {
773 let index = self.index.wrapping_add(1);
774 if index >= self.count as usize {
775 return Ok(None);
776 }
777
778 if let Some(parent) = self.parent.as_mut() {
779 self.offset = parent.get_limit();
780 parent.set_limit(self.offset + Self::block_length() as usize);
781 self.index = index;
782 Ok(Some(index))
783 } else {
784 Err(SbeErr::ParentNotSet)
785 }
786 }
787
788 #[inline]
798 pub fn prevented_match_id(&mut self, value: i64) {
799 let offset = self.offset;
800 self.get_buf_mut().put_i64_at(offset, value);
801 }
802
803 #[inline]
813 pub fn maker_order_id(&mut self, value: i64) {
814 let offset = self.offset + 8;
815 self.get_buf_mut().put_i64_at(offset, value);
816 }
817
818 #[inline]
828 pub fn price(&mut self, value: i64) {
829 let offset = self.offset + 16;
830 self.get_buf_mut().put_i64_at(offset, value);
831 }
832
833 #[inline]
843 pub fn taker_prevented_quantity(&mut self, value: i64) {
844 let offset = self.offset + 24;
845 self.get_buf_mut().put_i64_at(offset, value);
846 }
847
848 #[inline]
858 pub fn maker_prevented_quantity(&mut self, value: i64) {
859 let offset = self.offset + 32;
860 self.get_buf_mut().put_i64_at(offset, value);
861 }
862
863 #[inline]
865 pub fn maker_symbol(&mut self, value: &str) {
866 let limit = self.get_limit();
867 let data_length = value.len();
868 self.set_limit(limit + 1 + data_length);
869 self.get_buf_mut().put_u8_at(limit, data_length as u8);
870 self.get_buf_mut().put_slice_at(limit + 1, value.as_bytes());
871 }
872 }
873} pub mod decoder {
876 use message_header_codec::*;
877
878 use super::*;
879
880 #[derive(Clone, Copy, Debug, Default)]
881 pub struct NewOrderFullResponseDecoder<'a> {
882 buf: ReadBuf<'a>,
883 initial_offset: usize,
884 offset: usize,
885 limit: usize,
886 pub acting_block_length: u16,
887 pub acting_version: u16,
888 }
889
890 impl ActingVersion for NewOrderFullResponseDecoder<'_> {
891 #[inline]
892 fn acting_version(&self) -> u16 {
893 self.acting_version
894 }
895 }
896
897 impl<'a> Reader<'a> for NewOrderFullResponseDecoder<'a> {
898 #[inline]
899 fn get_buf(&self) -> &ReadBuf<'a> {
900 &self.buf
901 }
902 }
903
904 impl<'a> Decoder<'a> for NewOrderFullResponseDecoder<'a> {
905 #[inline]
906 fn get_limit(&self) -> usize {
907 self.limit
908 }
909
910 #[inline]
911 fn set_limit(&mut self, limit: usize) {
912 self.limit = limit;
913 }
914 }
915
916 impl<'a> NewOrderFullResponseDecoder<'a> {
917 pub fn wrap(
918 mut self,
919 buf: ReadBuf<'a>,
920 offset: usize,
921 acting_block_length: u16,
922 acting_version: u16,
923 ) -> Self {
924 let limit = offset + acting_block_length as usize;
925 self.buf = buf;
926 self.initial_offset = offset;
927 self.offset = offset;
928 self.limit = limit;
929 self.acting_block_length = acting_block_length;
930 self.acting_version = acting_version;
931 self
932 }
933
934 #[inline]
935 pub fn encoded_length(&self) -> usize {
936 self.limit - self.offset
937 }
938
939 pub fn header(self, mut header: MessageHeaderDecoder<ReadBuf<'a>>, offset: usize) -> Self {
940 debug_assert_eq!(SBE_TEMPLATE_ID, header.template_id());
941 let acting_block_length = header.block_length();
942 let acting_version = header.version();
943
944 self.wrap(
945 header.parent().unwrap(),
946 offset + message_header_codec::ENCODED_LENGTH,
947 acting_block_length,
948 acting_version,
949 )
950 }
951
952 #[inline]
954 pub fn price_exponent(&self) -> i8 {
955 self.get_buf().get_i8_at(self.offset)
956 }
957
958 #[inline]
960 pub fn qty_exponent(&self) -> i8 {
961 self.get_buf().get_i8_at(self.offset + 1)
962 }
963
964 #[inline]
966 pub fn order_id(&self) -> i64 {
967 self.get_buf().get_i64_at(self.offset + 2)
968 }
969
970 #[inline]
972 pub fn order_list_id(&self) -> Option<i64> {
973 let value = self.get_buf().get_i64_at(self.offset + 10);
974 if value == -9223372036854775808_i64 {
975 None
976 } else {
977 Some(value)
978 }
979 }
980
981 #[inline]
983 pub fn transact_time(&self) -> i64 {
984 self.get_buf().get_i64_at(self.offset + 18)
985 }
986
987 #[inline]
989 pub fn price(&self) -> i64 {
990 self.get_buf().get_i64_at(self.offset + 26)
991 }
992
993 #[inline]
995 pub fn orig_qty(&self) -> i64 {
996 self.get_buf().get_i64_at(self.offset + 34)
997 }
998
999 #[inline]
1001 pub fn executed_qty(&self) -> i64 {
1002 self.get_buf().get_i64_at(self.offset + 42)
1003 }
1004
1005 #[inline]
1007 pub fn cummulative_quote_qty(&self) -> i64 {
1008 self.get_buf().get_i64_at(self.offset + 50)
1009 }
1010
1011 #[inline]
1013 pub fn status(&self) -> order_status::OrderStatus {
1014 self.get_buf().get_u8_at(self.offset + 58).into()
1015 }
1016
1017 #[inline]
1019 pub fn time_in_force(&self) -> time_in_force::TimeInForce {
1020 self.get_buf().get_u8_at(self.offset + 59).into()
1021 }
1022
1023 #[inline]
1025 pub fn order_type(&self) -> order_type::OrderType {
1026 self.get_buf().get_u8_at(self.offset + 60).into()
1027 }
1028
1029 #[inline]
1031 pub fn side(&self) -> order_side::OrderSide {
1032 self.get_buf().get_u8_at(self.offset + 61).into()
1033 }
1034
1035 #[inline]
1037 pub fn stop_price(&self) -> Option<i64> {
1038 let value = self.get_buf().get_i64_at(self.offset + 62);
1039 if value == -9223372036854775808_i64 {
1040 None
1041 } else {
1042 Some(value)
1043 }
1044 }
1045
1046 #[inline]
1048 pub fn trailing_delta(&self) -> Option<i64> {
1049 let value = self.get_buf().get_i64_at(self.offset + 70);
1050 if value == -9223372036854775808_i64 {
1051 None
1052 } else {
1053 Some(value)
1054 }
1055 }
1056
1057 #[inline]
1059 pub fn trailing_time(&self) -> Option<i64> {
1060 let value = self.get_buf().get_i64_at(self.offset + 78);
1061 if value == -9223372036854775808_i64 {
1062 None
1063 } else {
1064 Some(value)
1065 }
1066 }
1067
1068 #[inline]
1070 pub fn working_time(&self) -> Option<i64> {
1071 let value = self.get_buf().get_i64_at(self.offset + 86);
1072 if value == -9223372036854775808_i64 {
1073 None
1074 } else {
1075 Some(value)
1076 }
1077 }
1078
1079 #[inline]
1081 pub fn iceberg_qty(&self) -> Option<i64> {
1082 let value = self.get_buf().get_i64_at(self.offset + 94);
1083 if value == -9223372036854775808_i64 {
1084 None
1085 } else {
1086 Some(value)
1087 }
1088 }
1089
1090 #[inline]
1092 pub fn strategy_id(&self) -> Option<i64> {
1093 let value = self.get_buf().get_i64_at(self.offset + 102);
1094 if value == -9223372036854775808_i64 {
1095 None
1096 } else {
1097 Some(value)
1098 }
1099 }
1100
1101 #[inline]
1103 pub fn strategy_type(&self) -> Option<i32> {
1104 let value = self.get_buf().get_i32_at(self.offset + 110);
1105 if value == -2147483648_i32 {
1106 None
1107 } else {
1108 Some(value)
1109 }
1110 }
1111
1112 #[inline]
1114 pub fn order_capacity(&self) -> order_capacity::OrderCapacity {
1115 self.get_buf().get_u8_at(self.offset + 114).into()
1116 }
1117
1118 #[inline]
1120 pub fn working_floor(&self) -> floor::Floor {
1121 self.get_buf().get_u8_at(self.offset + 115).into()
1122 }
1123
1124 #[inline]
1126 pub fn self_trade_prevention_mode(
1127 &self,
1128 ) -> self_trade_prevention_mode::SelfTradePreventionMode {
1129 self.get_buf().get_u8_at(self.offset + 116).into()
1130 }
1131
1132 #[inline]
1134 pub fn trade_group_id(&self) -> Option<i64> {
1135 let value = self.get_buf().get_i64_at(self.offset + 117);
1136 if value == -9223372036854775808_i64 {
1137 None
1138 } else {
1139 Some(value)
1140 }
1141 }
1142
1143 #[inline]
1145 pub fn prevented_quantity(&self) -> i64 {
1146 self.get_buf().get_i64_at(self.offset + 125)
1147 }
1148
1149 #[inline]
1151 pub fn used_sor(&self) -> bool_enum::BoolEnum {
1152 self.get_buf().get_u8_at(self.offset + 133).into()
1153 }
1154
1155 #[inline]
1157 pub fn orig_quote_order_qty(&self) -> i64 {
1158 self.get_buf().get_i64_at(self.offset + 134)
1159 }
1160
1161 #[inline]
1163 pub fn peg_price_type(&self) -> peg_price_type::PegPriceType {
1164 if self.acting_version() < 1 {
1165 return peg_price_type::PegPriceType::default();
1166 }
1167
1168 self.get_buf().get_u8_at(self.offset + 142).into()
1169 }
1170
1171 #[inline]
1173 pub fn peg_offset_type(&self) -> peg_offset_type::PegOffsetType {
1174 if self.acting_version() < 1 {
1175 return peg_offset_type::PegOffsetType::default();
1176 }
1177
1178 self.get_buf().get_u8_at(self.offset + 143).into()
1179 }
1180
1181 #[inline]
1183 pub fn peg_offset_value(&self) -> Option<u8> {
1184 if self.acting_version() < 1 {
1185 return None;
1186 }
1187
1188 let value = self.get_buf().get_u8_at(self.offset + 144);
1189 if value == 0xff_u8 { None } else { Some(value) }
1190 }
1191
1192 #[inline]
1194 pub fn pegged_price(&self) -> Option<i64> {
1195 if self.acting_version() < 1 {
1196 return None;
1197 }
1198
1199 let value = self.get_buf().get_i64_at(self.offset + 145);
1200 if value == -9223372036854775808_i64 {
1201 None
1202 } else {
1203 Some(value)
1204 }
1205 }
1206
1207 #[inline]
1209 pub fn expiry_reason(&self) -> expiry_reason::ExpiryReason {
1210 if self.acting_version() < 3 {
1211 return expiry_reason::ExpiryReason::default();
1212 }
1213
1214 self.get_buf().get_u8_at(self.offset + 153).into()
1215 }
1216
1217 #[inline]
1219 pub fn fills_decoder(self) -> FillsDecoder<Self> {
1220 FillsDecoder::default().wrap(self)
1221 }
1222
1223 #[inline]
1225 pub fn prevented_matches_decoder(self) -> PreventedMatchesDecoder<Self> {
1226 PreventedMatchesDecoder::default().wrap(self)
1227 }
1228
1229 #[inline]
1231 pub fn symbol_decoder(&mut self) -> (usize, usize) {
1232 let offset = self.get_limit();
1233 let data_length = self.get_buf().get_u8_at(offset) as usize;
1234 self.set_limit(offset + 1 + data_length);
1235 (offset + 1, data_length)
1236 }
1237
1238 #[inline]
1239 pub fn symbol_slice(&'a self, coordinates: (usize, usize)) -> &'a [u8] {
1240 debug_assert!(self.get_limit() >= coordinates.0 + coordinates.1);
1241 self.get_buf().get_slice_at(coordinates.0, coordinates.1)
1242 }
1243
1244 #[inline]
1246 pub fn client_order_id_decoder(&mut self) -> (usize, usize) {
1247 let offset = self.get_limit();
1248 let data_length = self.get_buf().get_u8_at(offset) as usize;
1249 self.set_limit(offset + 1 + data_length);
1250 (offset + 1, data_length)
1251 }
1252
1253 #[inline]
1254 pub fn client_order_id_slice(&'a self, coordinates: (usize, usize)) -> &'a [u8] {
1255 debug_assert!(self.get_limit() >= coordinates.0 + coordinates.1);
1256 self.get_buf().get_slice_at(coordinates.0, coordinates.1)
1257 }
1258 }
1259
1260 #[derive(Debug, Default)]
1261 pub struct FillsDecoder<P> {
1262 parent: Option<P>,
1263 block_length: u16,
1264 count: u32,
1265 index: usize,
1266 offset: usize,
1267 }
1268
1269 impl<'a, P> ActingVersion for FillsDecoder<P>
1270 where
1271 P: Reader<'a> + ActingVersion + Default,
1272 {
1273 #[inline]
1274 fn acting_version(&self) -> u16 {
1275 self.parent.as_ref().unwrap().acting_version()
1276 }
1277 }
1278
1279 impl<'a, P> Reader<'a> for FillsDecoder<P>
1280 where
1281 P: Reader<'a> + Default,
1282 {
1283 #[inline]
1284 fn get_buf(&self) -> &ReadBuf<'a> {
1285 self.parent.as_ref().expect("parent missing").get_buf()
1286 }
1287 }
1288
1289 impl<'a, P> Decoder<'a> for FillsDecoder<P>
1290 where
1291 P: Decoder<'a> + ActingVersion + Default,
1292 {
1293 #[inline]
1294 fn get_limit(&self) -> usize {
1295 self.parent.as_ref().expect("parent missing").get_limit()
1296 }
1297
1298 #[inline]
1299 fn set_limit(&mut self, limit: usize) {
1300 self.parent
1301 .as_mut()
1302 .expect("parent missing")
1303 .set_limit(limit);
1304 }
1305 }
1306
1307 impl<'a, P> FillsDecoder<P>
1308 where
1309 P: Decoder<'a> + ActingVersion + Default,
1310 {
1311 pub fn wrap(mut self, mut parent: P) -> Self {
1312 let initial_offset = parent.get_limit();
1313 let block_length = parent.get_buf().get_u16_at(initial_offset);
1314 let count = parent.get_buf().get_u32_at(initial_offset + 2);
1315 parent.set_limit(initial_offset + 6);
1316 self.parent = Some(parent);
1317 self.block_length = block_length;
1318 self.count = count;
1319 self.index = usize::MAX;
1320 self.offset = 0;
1321 self
1322 }
1323
1324 #[inline]
1326 pub fn parent(&mut self) -> SbeResult<P> {
1327 self.parent.take().ok_or(SbeErr::ParentNotSet)
1328 }
1329
1330 #[inline]
1331 pub fn acting_version(&mut self) -> u16 {
1332 self.parent.as_ref().unwrap().acting_version()
1333 }
1334
1335 #[inline]
1336 pub fn count(&self) -> u32 {
1337 self.count
1338 }
1339
1340 pub fn advance(&mut self) -> SbeResult<Option<usize>> {
1342 let index = self.index.wrapping_add(1);
1343 if index >= self.count as usize {
1344 return Ok(None);
1345 }
1346
1347 if let Some(parent) = self.parent.as_mut() {
1348 self.offset = parent.get_limit();
1349 parent.set_limit(self.offset + self.block_length as usize);
1350 self.index = index;
1351 Ok(Some(index))
1352 } else {
1353 Err(SbeErr::ParentNotSet)
1354 }
1355 }
1356
1357 #[inline]
1359 pub fn commission_exponent(&self) -> i8 {
1360 self.get_buf().get_i8_at(self.offset)
1361 }
1362
1363 #[inline]
1365 pub fn match_type(&self) -> match_type::MatchType {
1366 self.get_buf().get_u8_at(self.offset + 1).into()
1367 }
1368
1369 #[inline]
1371 pub fn price(&self) -> i64 {
1372 self.get_buf().get_i64_at(self.offset + 2)
1373 }
1374
1375 #[inline]
1377 pub fn qty(&self) -> i64 {
1378 self.get_buf().get_i64_at(self.offset + 10)
1379 }
1380
1381 #[inline]
1383 pub fn commission(&self) -> i64 {
1384 self.get_buf().get_i64_at(self.offset + 18)
1385 }
1386
1387 #[inline]
1389 pub fn trade_id(&self) -> Option<i64> {
1390 let value = self.get_buf().get_i64_at(self.offset + 26);
1391 if value == -9223372036854775808_i64 {
1392 None
1393 } else {
1394 Some(value)
1395 }
1396 }
1397
1398 #[inline]
1400 pub fn alloc_id(&self) -> Option<i64> {
1401 let value = self.get_buf().get_i64_at(self.offset + 34);
1402 if value == -9223372036854775808_i64 {
1403 None
1404 } else {
1405 Some(value)
1406 }
1407 }
1408
1409 #[inline]
1411 pub fn commission_asset_decoder(&mut self) -> (usize, usize) {
1412 let offset = self.parent.as_ref().expect("parent missing").get_limit();
1413 let data_length = self.get_buf().get_u8_at(offset) as usize;
1414 self.parent
1415 .as_mut()
1416 .unwrap()
1417 .set_limit(offset + 1 + data_length);
1418 (offset + 1, data_length)
1419 }
1420
1421 #[inline]
1422 pub fn commission_asset_slice(&'a self, coordinates: (usize, usize)) -> &'a [u8] {
1423 debug_assert!(self.get_limit() >= coordinates.0 + coordinates.1);
1424 self.get_buf().get_slice_at(coordinates.0, coordinates.1)
1425 }
1426 }
1427
1428 #[derive(Debug, Default)]
1429 pub struct PreventedMatchesDecoder<P> {
1430 parent: Option<P>,
1431 block_length: u16,
1432 count: u32,
1433 index: usize,
1434 offset: usize,
1435 }
1436
1437 impl<'a, P> ActingVersion for PreventedMatchesDecoder<P>
1438 where
1439 P: Reader<'a> + ActingVersion + Default,
1440 {
1441 #[inline]
1442 fn acting_version(&self) -> u16 {
1443 self.parent.as_ref().unwrap().acting_version()
1444 }
1445 }
1446
1447 impl<'a, P> Reader<'a> for PreventedMatchesDecoder<P>
1448 where
1449 P: Reader<'a> + Default,
1450 {
1451 #[inline]
1452 fn get_buf(&self) -> &ReadBuf<'a> {
1453 self.parent.as_ref().expect("parent missing").get_buf()
1454 }
1455 }
1456
1457 impl<'a, P> Decoder<'a> for PreventedMatchesDecoder<P>
1458 where
1459 P: Decoder<'a> + ActingVersion + Default,
1460 {
1461 #[inline]
1462 fn get_limit(&self) -> usize {
1463 self.parent.as_ref().expect("parent missing").get_limit()
1464 }
1465
1466 #[inline]
1467 fn set_limit(&mut self, limit: usize) {
1468 self.parent
1469 .as_mut()
1470 .expect("parent missing")
1471 .set_limit(limit);
1472 }
1473 }
1474
1475 impl<'a, P> PreventedMatchesDecoder<P>
1476 where
1477 P: Decoder<'a> + ActingVersion + Default,
1478 {
1479 pub fn wrap(mut self, mut parent: P) -> Self {
1480 let initial_offset = parent.get_limit();
1481 let block_length = parent.get_buf().get_u16_at(initial_offset);
1482 let count = parent.get_buf().get_u32_at(initial_offset + 2);
1483 parent.set_limit(initial_offset + 6);
1484 self.parent = Some(parent);
1485 self.block_length = block_length;
1486 self.count = count;
1487 self.index = usize::MAX;
1488 self.offset = 0;
1489 self
1490 }
1491
1492 #[inline]
1494 pub fn parent(&mut self) -> SbeResult<P> {
1495 self.parent.take().ok_or(SbeErr::ParentNotSet)
1496 }
1497
1498 #[inline]
1499 pub fn acting_version(&mut self) -> u16 {
1500 self.parent.as_ref().unwrap().acting_version()
1501 }
1502
1503 #[inline]
1504 pub fn count(&self) -> u32 {
1505 self.count
1506 }
1507
1508 pub fn advance(&mut self) -> SbeResult<Option<usize>> {
1510 let index = self.index.wrapping_add(1);
1511 if index >= self.count as usize {
1512 return Ok(None);
1513 }
1514
1515 if let Some(parent) = self.parent.as_mut() {
1516 self.offset = parent.get_limit();
1517 parent.set_limit(self.offset + self.block_length as usize);
1518 self.index = index;
1519 Ok(Some(index))
1520 } else {
1521 Err(SbeErr::ParentNotSet)
1522 }
1523 }
1524
1525 #[inline]
1527 pub fn prevented_match_id(&self) -> i64 {
1528 self.get_buf().get_i64_at(self.offset)
1529 }
1530
1531 #[inline]
1533 pub fn maker_order_id(&self) -> Option<i64> {
1534 let value = self.get_buf().get_i64_at(self.offset + 8);
1535 if value == -9223372036854775808_i64 {
1536 None
1537 } else {
1538 Some(value)
1539 }
1540 }
1541
1542 #[inline]
1544 pub fn price(&self) -> Option<i64> {
1545 let value = self.get_buf().get_i64_at(self.offset + 16);
1546 if value == -9223372036854775808_i64 {
1547 None
1548 } else {
1549 Some(value)
1550 }
1551 }
1552
1553 #[inline]
1555 pub fn taker_prevented_quantity(&self) -> Option<i64> {
1556 let value = self.get_buf().get_i64_at(self.offset + 24);
1557 if value == -9223372036854775808_i64 {
1558 None
1559 } else {
1560 Some(value)
1561 }
1562 }
1563
1564 #[inline]
1566 pub fn maker_prevented_quantity(&self) -> Option<i64> {
1567 let value = self.get_buf().get_i64_at(self.offset + 32);
1568 if value == -9223372036854775808_i64 {
1569 None
1570 } else {
1571 Some(value)
1572 }
1573 }
1574
1575 #[inline]
1577 pub fn maker_symbol_decoder(&mut self) -> (usize, usize) {
1578 let offset = self.parent.as_ref().expect("parent missing").get_limit();
1579 let data_length = self.get_buf().get_u8_at(offset) as usize;
1580 self.parent
1581 .as_mut()
1582 .unwrap()
1583 .set_limit(offset + 1 + data_length);
1584 (offset + 1, data_length)
1585 }
1586
1587 #[inline]
1588 pub fn maker_symbol_slice(&'a self, coordinates: (usize, usize)) -> &'a [u8] {
1589 debug_assert!(self.get_limit() >= coordinates.0 + coordinates.1);
1590 self.get_buf().get_slice_at(coordinates.0, coordinates.1)
1591 }
1592 }
1593}