Skip to main content

nautilus_binance/spot/sbe/generated/
mod.rs

1//! Generated SBE codecs for Binance Spot API (schema 3:3).
2//!
3//! This code is auto-generated by Real Logic's SBE generator from Binance's
4//! official XML schema. Do not edit manually.
5
6#![forbid(unsafe_code)]
7#![allow(clippy::all)]
8#![expect(clippy::missing_errors_doc)]
9#![expect(clippy::missing_panics_doc)]
10#![expect(clippy::return_self_not_must_use)]
11#![expect(clippy::semicolon_if_nothing_returned)]
12#![expect(clippy::use_self)]
13#![allow(missing_docs)]
14#![allow(non_camel_case_types)]
15#![allow(ambiguous_glob_reexports)]
16#![allow(unused_imports)]
17#![allow(dead_code)]
18
19use ::core::convert::TryInto;
20
21pub mod account_commission_response_codec;
22pub mod account_order_rate_limit_response_codec;
23pub mod account_prevented_matches_response_codec;
24pub mod account_response_codec;
25pub mod account_trades_response_codec;
26pub mod account_type;
27pub mod agg_trades_response_codec;
28pub mod allowed_self_trade_prevention_modes;
29pub mod average_price_response_codec;
30pub mod balance_update_event_codec;
31pub mod book_ticker_response_codec;
32pub mod book_ticker_symbol_response_codec;
33pub mod bool_enum;
34pub mod calculation_type;
35pub mod cancel_open_orders_response_codec;
36pub mod cancel_order_list_response_codec;
37pub mod cancel_order_response_codec;
38pub mod cancel_replace_order_response_codec;
39pub mod cancel_replace_status;
40pub mod contingency_type;
41pub mod depth_response_codec;
42pub mod error_response_codec;
43pub mod event_stream_terminated_event_codec;
44pub mod exchange_info_response_codec;
45pub mod exchange_max_num_algo_orders_filter_codec;
46pub mod exchange_max_num_iceberg_orders_filter_codec;
47pub mod exchange_max_num_order_lists_filter_codec;
48pub mod exchange_max_num_orders_filter_codec;
49pub mod execution_report_event_codec;
50pub mod execution_rule_type;
51pub mod execution_rules_response_codec;
52pub mod execution_type;
53pub mod expiry_reason;
54pub mod external_lock_update_event_codec;
55pub mod filter_type;
56pub mod floor;
57pub mod group_size_16_encoding_codec;
58pub mod group_size_encoding_codec;
59pub mod iceberg_parts_filter_codec;
60pub mod klines_response_codec;
61pub mod list_order_status;
62pub mod list_status_event_codec;
63pub mod list_status_type;
64pub mod lot_size_filter_codec;
65pub mod market_lot_size_filter_codec;
66pub mod match_type;
67pub mod max_asset_filter_codec;
68pub mod max_num_algo_orders_filter_codec;
69pub mod max_num_iceberg_orders_filter_codec;
70pub mod max_num_order_amends_filter_codec;
71pub mod max_num_order_lists_filter_codec;
72pub mod max_num_orders_filter_codec;
73pub mod max_position_filter_codec;
74pub mod message_data_16_codec;
75pub mod message_data_8_codec;
76pub mod message_data_codec;
77pub mod message_header_codec;
78pub mod min_notional_filter_codec;
79pub mod my_filters_response_codec;
80pub mod new_order_ack_response_codec;
81pub mod new_order_full_response_codec;
82pub mod new_order_list_ack_response_codec;
83pub mod new_order_list_full_response_codec;
84pub mod new_order_list_result_response_codec;
85pub mod new_order_result_response_codec;
86pub mod non_representable_message_codec;
87pub mod notional_filter_codec;
88pub mod optional_message_data_16_codec;
89pub mod optional_message_data_codec;
90pub mod optional_var_string_8_codec;
91pub mod optional_var_string_codec;
92pub mod order_capacity;
93pub mod order_list_response_codec;
94pub mod order_lists_response_codec;
95pub mod order_response_codec;
96pub mod order_side;
97pub mod order_status;
98pub mod order_test_response_codec;
99pub mod order_test_with_commissions_response_codec;
100pub mod order_type;
101pub mod order_types;
102pub mod orders_response_codec;
103pub mod outbound_account_position_event_codec;
104pub mod peg_offset_type;
105pub mod peg_price_type;
106pub mod percent_price_by_side_filter_codec;
107pub mod percent_price_filter_codec;
108pub mod ping_response_codec;
109pub mod price_filter_codec;
110pub mod price_range_execution_rule_codec;
111pub mod price_ticker_response_codec;
112pub mod price_ticker_symbol_response_codec;
113pub mod rate_limit_interval;
114pub mod rate_limit_type;
115pub mod reference_price_calculation_response_codec;
116pub mod reference_price_response_codec;
117pub mod self_trade_prevention_mode;
118pub mod server_shutdown_event_codec;
119pub mod server_time_response_codec;
120pub mod symbol_status;
121pub mod ticker_24_hf_ull_response_codec;
122pub mod ticker_24_hm_ini_response_codec;
123pub mod ticker_24_hs_ymbol_full_response_codec;
124pub mod ticker_24_hs_ymbol_mini_response_codec;
125pub mod ticker_full_response_codec;
126pub mod ticker_mini_response_codec;
127pub mod ticker_symbol_full_response_codec;
128pub mod ticker_symbol_mini_response_codec;
129pub mod time_in_force;
130pub mod tp_lus_sell_filter_codec;
131pub mod trades_response_codec;
132pub mod trailing_delta_filter_codec;
133pub mod var_string_8_codec;
134pub mod var_string_codec;
135pub mod web_socket_response_codec;
136pub mod web_socket_session_logon_response_codec;
137pub mod web_socket_session_logout_response_codec;
138pub mod web_socket_session_status_response_codec;
139pub mod web_socket_session_subscriptions_response_codec;
140
141pub const SBE_SCHEMA_ID: u16 = 3;
142pub const SBE_SCHEMA_VERSION: u16 = 3;
143pub const SBE_SEMANTIC_VERSION: &str = "5.2";
144
145pub type SbeResult<T> = core::result::Result<T, SbeErr>;
146
147#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
148pub enum SbeErr {
149    ParentNotSet,
150}
151impl core::fmt::Display for SbeErr {
152    #[inline]
153    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
154        write!(f, "{self:?}")
155    }
156}
157impl std::error::Error for SbeErr {}
158
159#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
160pub enum Either<L, R> {
161    Left(L),
162    Right(R),
163}
164
165pub trait Writer<'a>: Sized {
166    fn get_buf_mut(&mut self) -> &mut WriteBuf<'a>;
167}
168
169pub trait Encoder<'a>: Writer<'a> {
170    fn get_limit(&self) -> usize;
171    fn set_limit(&mut self, limit: usize);
172}
173
174pub trait ActingVersion {
175    fn acting_version(&self) -> u16;
176}
177
178pub trait Reader<'a>: Sized {
179    fn get_buf(&self) -> &ReadBuf<'a>;
180}
181
182pub trait Decoder<'a>: Reader<'a> {
183    fn get_limit(&self) -> usize;
184    fn set_limit(&mut self, limit: usize);
185}
186
187#[derive(Clone, Copy, Debug, Default)]
188pub struct ReadBuf<'a> {
189    data: &'a [u8],
190}
191impl<'a> Reader<'a> for ReadBuf<'a> {
192    #[inline]
193    fn get_buf(&self) -> &ReadBuf<'a> {
194        self
195    }
196}
197#[allow(dead_code)]
198impl<'a> ReadBuf<'a> {
199    #[inline]
200    pub fn new(data: &'a [u8]) -> Self {
201        Self { data }
202    }
203
204    #[inline]
205    pub(crate) fn get_bytes_at<const N: usize>(slice: &[u8], index: usize) -> [u8; N] {
206        slice[index..index + N]
207            .try_into()
208            .expect("slice with incorrect length")
209    }
210
211    #[inline]
212    pub fn get_u8_at(&self, index: usize) -> u8 {
213        self.data[index]
214    }
215
216    #[inline]
217    pub fn get_i8_at(&self, index: usize) -> i8 {
218        i8::from_le_bytes(Self::get_bytes_at(self.data, index))
219    }
220
221    #[inline]
222    pub fn get_i16_at(&self, index: usize) -> i16 {
223        i16::from_le_bytes(Self::get_bytes_at(self.data, index))
224    }
225
226    #[inline]
227    pub fn get_i32_at(&self, index: usize) -> i32 {
228        i32::from_le_bytes(Self::get_bytes_at(self.data, index))
229    }
230
231    #[inline]
232    pub fn get_i64_at(&self, index: usize) -> i64 {
233        i64::from_le_bytes(Self::get_bytes_at(self.data, index))
234    }
235
236    #[inline]
237    pub fn get_u16_at(&self, index: usize) -> u16 {
238        u16::from_le_bytes(Self::get_bytes_at(self.data, index))
239    }
240
241    #[inline]
242    pub fn get_u32_at(&self, index: usize) -> u32 {
243        u32::from_le_bytes(Self::get_bytes_at(self.data, index))
244    }
245
246    #[inline]
247    pub fn get_u64_at(&self, index: usize) -> u64 {
248        u64::from_le_bytes(Self::get_bytes_at(self.data, index))
249    }
250
251    #[inline]
252    pub fn get_f32_at(&self, index: usize) -> f32 {
253        f32::from_le_bytes(Self::get_bytes_at(self.data, index))
254    }
255
256    #[inline]
257    pub fn get_f64_at(&self, index: usize) -> f64 {
258        f64::from_le_bytes(Self::get_bytes_at(self.data, index))
259    }
260
261    #[inline]
262    pub fn get_slice_at(&self, index: usize, len: usize) -> &[u8] {
263        &self.data[index..index + len]
264    }
265}
266
267#[derive(Debug, Default)]
268pub struct WriteBuf<'a> {
269    data: &'a mut [u8],
270}
271impl<'a> WriteBuf<'a> {
272    pub fn new(data: &'a mut [u8]) -> Self {
273        Self { data }
274    }
275
276    #[inline]
277    pub fn put_bytes_at<const COUNT: usize>(&mut self, index: usize, bytes: &[u8; COUNT]) -> usize {
278        self.data[index..index + COUNT].copy_from_slice(bytes);
279        COUNT
280    }
281
282    #[inline]
283    pub fn put_u8_at(&mut self, index: usize, value: u8) {
284        self.data[index] = value;
285    }
286
287    #[inline]
288    pub fn put_i8_at(&mut self, index: usize, value: i8) {
289        self.put_bytes_at(index, &i8::to_le_bytes(value));
290    }
291
292    #[inline]
293    pub fn put_i16_at(&mut self, index: usize, value: i16) {
294        self.put_bytes_at(index, &i16::to_le_bytes(value));
295    }
296
297    #[inline]
298    pub fn put_i32_at(&mut self, index: usize, value: i32) {
299        self.put_bytes_at(index, &i32::to_le_bytes(value));
300    }
301
302    #[inline]
303    pub fn put_i64_at(&mut self, index: usize, value: i64) {
304        self.put_bytes_at(index, &i64::to_le_bytes(value));
305    }
306
307    #[inline]
308    pub fn put_u16_at(&mut self, index: usize, value: u16) {
309        self.put_bytes_at(index, &u16::to_le_bytes(value));
310    }
311
312    #[inline]
313    pub fn put_u32_at(&mut self, index: usize, value: u32) {
314        self.put_bytes_at(index, &u32::to_le_bytes(value));
315    }
316
317    #[inline]
318    pub fn put_u64_at(&mut self, index: usize, value: u64) {
319        self.put_bytes_at(index, &u64::to_le_bytes(value));
320    }
321
322    #[inline]
323    pub fn put_f32_at(&mut self, index: usize, value: f32) {
324        self.put_bytes_at(index, &f32::to_le_bytes(value));
325    }
326
327    #[inline]
328    pub fn put_f64_at(&mut self, index: usize, value: f64) {
329        self.put_bytes_at(index, &f64::to_le_bytes(value));
330    }
331
332    #[inline]
333    pub fn put_slice_at(&mut self, index: usize, src: &[u8]) -> usize {
334        let len = src.len();
335        let dest = self.data.split_at_mut(index).1.split_at_mut(len).0;
336        dest.clone_from_slice(src);
337        len
338    }
339}
340impl<'a> From<&'a mut WriteBuf<'a>> for &'a mut [u8] {
341    #[inline]
342    fn from(buf: &'a mut WriteBuf<'a>) -> &'a mut [u8] {
343        buf.data
344    }
345}