/rust/registry/src/index.crates.io-6f17d22bba15001f/bincode-1.3.3/src/config/mod.rs
Line | Count | Source (jump to first uncovered line) |
1 | | //! `bincode` uses a Builder-pattern to configure the Serializers and Deserializers in this |
2 | | //! crate. This means that if you need to customize the behavior of `bincode`, you should create an |
3 | | //! instance of the `DefaultOptions` struct: |
4 | | //! |
5 | | //! ```rust |
6 | | //! use bincode::Options; |
7 | | //! let my_options = bincode::DefaultOptions::new(); |
8 | | //! ``` |
9 | | //! |
10 | | //! # Options Struct vs bincode functions |
11 | | //! |
12 | | //! Due to historical reasons, the default options used by the `serialize()` and `deserialize()` |
13 | | //! family of functions are different than the default options created by the `DefaultOptions` struct: |
14 | | //! |
15 | | //! | | Byte limit | Endianness | Int Encoding | Trailing Behavior | |
16 | | //! |----------|------------|------------|--------------|-------------------| |
17 | | //! | struct | Unlimited | Little | Varint | Reject | |
18 | | //! | function | Unlimited | Little | Fixint | Allow | |
19 | | //! |
20 | | //! This means that if you want to use the `Serialize` / `Deserialize` structs with the same |
21 | | //! settings as the functions, you should adjust the `DefaultOptions` struct like so: |
22 | | //! |
23 | | //! ```rust |
24 | | //! use bincode::Options; |
25 | | //! let my_options = bincode::DefaultOptions::new() |
26 | | //! .with_fixint_encoding() |
27 | | //! .allow_trailing_bytes(); |
28 | | //! ``` |
29 | | |
30 | | use de::read::BincodeRead; |
31 | | use error::Result; |
32 | | use serde; |
33 | | use std::io::{Read, Write}; |
34 | | use std::marker::PhantomData; |
35 | | |
36 | | pub(crate) use self::endian::BincodeByteOrder; |
37 | | pub(crate) use self::int::IntEncoding; |
38 | | pub(crate) use self::internal::*; |
39 | | pub(crate) use self::limit::SizeLimit; |
40 | | pub(crate) use self::trailing::TrailingBytes; |
41 | | |
42 | | pub use self::endian::{BigEndian, LittleEndian, NativeEndian}; |
43 | | pub use self::int::{FixintEncoding, VarintEncoding}; |
44 | | pub use self::legacy::*; |
45 | | pub use self::limit::{Bounded, Infinite}; |
46 | | pub use self::trailing::{AllowTrailing, RejectTrailing}; |
47 | | |
48 | | mod endian; |
49 | | mod int; |
50 | | mod legacy; |
51 | | mod limit; |
52 | | mod trailing; |
53 | | |
54 | | /// The default options for bincode serialization/deserialization. |
55 | | /// |
56 | | /// ### Defaults |
57 | | /// By default bincode will use little-endian encoding for multi-byte integers, and will not |
58 | | /// limit the number of serialized/deserialized bytes. |
59 | | /// |
60 | | /// ### Configuring `DefaultOptions` |
61 | | /// |
62 | | /// `DefaultOptions` implements the [Options] trait, which means it exposes functions to change the behavior of bincode. |
63 | | /// |
64 | | /// For example, if you wanted to limit the bincode deserializer to 1 kilobyte of user input: |
65 | | /// |
66 | | /// ```rust |
67 | | /// use bincode::Options; |
68 | | /// let my_options = bincode::DefaultOptions::new().with_limit(1024); |
69 | | /// ``` |
70 | | /// |
71 | | /// ### DefaultOptions struct vs. functions |
72 | | /// |
73 | | /// The default configuration used by this struct is not the same as that used by the bincode |
74 | | /// helper functions in the root of this crate. See the |
75 | | /// [config](index.html#options-struct-vs-bincode-functions) module for more details |
76 | | #[derive(Copy, Clone)] |
77 | | pub struct DefaultOptions(Infinite); |
78 | | |
79 | | impl DefaultOptions { |
80 | | /// Get a default configuration object. |
81 | | /// |
82 | | /// ### Default Configuration: |
83 | | /// |
84 | | /// | Byte limit | Endianness | Int Encoding | Trailing Behavior | |
85 | | /// |------------|------------|--------------|-------------------| |
86 | | /// | Unlimited | Little | Varint | Reject | |
87 | 0 | pub fn new() -> DefaultOptions { |
88 | 0 | DefaultOptions(Infinite) |
89 | 0 | } |
90 | | } |
91 | | |
92 | | impl Default for DefaultOptions { |
93 | 0 | fn default() -> Self { |
94 | 0 | Self::new() |
95 | 0 | } |
96 | | } |
97 | | |
98 | | impl InternalOptions for DefaultOptions { |
99 | | type Limit = Infinite; |
100 | | type Endian = LittleEndian; |
101 | | type IntEncoding = VarintEncoding; |
102 | | type Trailing = RejectTrailing; |
103 | | |
104 | | #[inline(always)] |
105 | 0 | fn limit(&mut self) -> &mut Infinite { |
106 | 0 | &mut self.0 |
107 | 0 | } |
108 | | } |
109 | | |
110 | | /// A configuration builder trait whose options Bincode will use |
111 | | /// while serializing and deserializing. |
112 | | /// |
113 | | /// ### Options |
114 | | /// Endianness: The endianness with which multi-byte integers will be read/written. *default: little endian* |
115 | | /// |
116 | | /// Limit: The maximum number of bytes that will be read/written in a bincode serialize/deserialize. *default: unlimited* |
117 | | /// |
118 | | /// Int Encoding: The encoding used for numbers, enum discriminants, and lengths. *default: varint* |
119 | | /// |
120 | | /// Trailing Behavior: The behavior when there are trailing bytes left over in a slice after deserialization. *default: reject* |
121 | | /// |
122 | | /// ### Byte Limit Details |
123 | | /// The purpose of byte-limiting is to prevent Denial-Of-Service attacks whereby malicious attackers get bincode |
124 | | /// deserialization to crash your process by allocating too much memory or keeping a connection open for too long. |
125 | | /// |
126 | | /// When a byte limit is set, bincode will return `Err` on any deserialization that goes over the limit, or any |
127 | | /// serialization that goes over the limit. |
128 | | pub trait Options: InternalOptions + Sized { |
129 | | /// Sets the byte limit to be unlimited. |
130 | | /// This is the default. |
131 | 0 | fn with_no_limit(self) -> WithOtherLimit<Self, Infinite> { |
132 | 0 | WithOtherLimit::new(self, Infinite) |
133 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::Options>::with_no_limit Unexecuted instantiation: <bincode::config::DefaultOptions as bincode::config::Options>::with_no_limit Unexecuted instantiation: <_ as bincode::config::Options>::with_no_limit |
134 | | |
135 | | /// Sets the byte limit to `limit`. |
136 | 0 | fn with_limit(self, limit: u64) -> WithOtherLimit<Self, Bounded> { |
137 | 0 | WithOtherLimit::new(self, Bounded(limit)) |
138 | 0 | } |
139 | | |
140 | | /// Sets the endianness to little-endian |
141 | | /// This is the default. |
142 | 0 | fn with_little_endian(self) -> WithOtherEndian<Self, LittleEndian> { |
143 | 0 | WithOtherEndian::new(self) |
144 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherLimit<bincode::config::DefaultOptions, bincode::config::limit::Infinite> as bincode::config::Options>::with_little_endian Unexecuted instantiation: <_ as bincode::config::Options>::with_little_endian |
145 | | |
146 | | /// Sets the endianness to big-endian |
147 | 0 | fn with_big_endian(self) -> WithOtherEndian<Self, BigEndian> { |
148 | 0 | WithOtherEndian::new(self) |
149 | 0 | } |
150 | | |
151 | | /// Sets the endianness to the the machine-native endianness |
152 | 0 | fn with_native_endian(self) -> WithOtherEndian<Self, NativeEndian> { |
153 | 0 | WithOtherEndian::new(self) |
154 | 0 | } |
155 | | |
156 | | /// Sets the length encoding to varint |
157 | 0 | fn with_varint_encoding(self) -> WithOtherIntEncoding<Self, VarintEncoding> { |
158 | 0 | WithOtherIntEncoding::new(self) |
159 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherEndian<bincode::config::WithOtherLimit<bincode::config::DefaultOptions, bincode::config::limit::Infinite>, bincode::config::endian::LittleEndian> as bincode::config::Options>::with_varint_encoding Unexecuted instantiation: <_ as bincode::config::Options>::with_varint_encoding |
160 | | |
161 | | /// Sets the length encoding to be fixed |
162 | 0 | fn with_fixint_encoding(self) -> WithOtherIntEncoding<Self, FixintEncoding> { |
163 | 0 | WithOtherIntEncoding::new(self) |
164 | 0 | } Unexecuted instantiation: <bincode::config::DefaultOptions as bincode::config::Options>::with_fixint_encoding Unexecuted instantiation: <_ as bincode::config::Options>::with_fixint_encoding |
165 | | |
166 | | /// Sets the deserializer to reject trailing bytes |
167 | 0 | fn reject_trailing_bytes(self) -> WithOtherTrailing<Self, RejectTrailing> { |
168 | 0 | WithOtherTrailing::new(self) |
169 | 0 | } |
170 | | |
171 | | /// Sets the deserializer to allow trailing bytes |
172 | 0 | fn allow_trailing_bytes(self) -> WithOtherTrailing<Self, AllowTrailing> { |
173 | 0 | WithOtherTrailing::new(self) |
174 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<bincode::config::WithOtherEndian<bincode::config::WithOtherLimit<bincode::config::DefaultOptions, bincode::config::limit::Infinite>, bincode::config::endian::LittleEndian>, bincode::config::int::VarintEncoding> as bincode::config::Options>::allow_trailing_bytes Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding> as bincode::config::Options>::allow_trailing_bytes Unexecuted instantiation: <_ as bincode::config::Options>::allow_trailing_bytes |
175 | | |
176 | | /// Serializes a serializable object into a `Vec` of bytes using this configuration |
177 | | #[inline(always)] |
178 | 0 | fn serialize<S: ?Sized + serde::Serialize>(self, t: &S) -> Result<Vec<u8>> { |
179 | 0 | ::internal::serialize(t, self) |
180 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::Options>::serialize::<alloc::vec::Vec<u32>> Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::Options>::serialize::<surrealdb_core::idg::u32::State> Unexecuted instantiation: <_ as bincode::config::Options>::serialize::<_> |
181 | | |
182 | | /// Returns the size that an object would be if serialized using Bincode with this configuration |
183 | | #[inline(always)] |
184 | 0 | fn serialized_size<T: ?Sized + serde::Serialize>(self, t: &T) -> Result<u64> { |
185 | 0 | ::internal::serialized_size(t, self) |
186 | 0 | } |
187 | | |
188 | | /// Serializes an object directly into a `Writer` using this configuration |
189 | | /// |
190 | | /// If the serialization would take more bytes than allowed by the size limit, an error |
191 | | /// is returned and *no bytes* will be written into the `Writer` |
192 | | #[inline(always)] |
193 | 0 | fn serialize_into<W: Write, T: ?Sized + serde::Serialize>(self, w: W, t: &T) -> Result<()> { |
194 | 0 | ::internal::serialize_into(w, t, self) |
195 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding> as bincode::config::Options>::serialize_into::<&mut alloc::vec::Vec<u8>, radix_trie::Trie<alloc::vec::Vec<u8>, u64>> Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding> as bincode::config::Options>::serialize_into::<&mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>, alloc::vec::Vec<u8>> Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding> as bincode::config::Options>::serialize_into::<&mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>, std::collections::hash::map::HashMap<surrealdb_core::idx::trees::vector::SharedVector, surrealdb_core::idx::trees::mtree::ObjectProperties, ahash::random_state::RandomState>> Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding> as bincode::config::Options>::serialize_into::<&mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>, std::collections::hash::map::HashMap<surrealdb_core::idx::trees::vector::SharedVector, surrealdb_core::idx::trees::mtree::RoutingProperties, ahash::random_state::RandomState>> Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding> as bincode::config::Options>::serialize_into::<&mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>, &alloc::vec::Vec<u64>> Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding> as bincode::config::Options>::serialize_into::<&mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>, [u8]> Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding> as bincode::config::Options>::serialize_into::<&mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>, u8> Unexecuted instantiation: <_ as bincode::config::Options>::serialize_into::<_, _> |
196 | | |
197 | | /// Deserializes a slice of bytes into an instance of `T` using this configuration |
198 | | #[inline(always)] |
199 | 0 | fn deserialize<'a, T: serde::Deserialize<'a>>(self, bytes: &'a [u8]) -> Result<T> { |
200 | 0 | ::internal::deserialize(bytes, self) |
201 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::Options>::deserialize::<alloc::vec::Vec<u32>> Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::Options>::deserialize::<surrealdb_core::idg::u32::State> Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::WithOtherEndian<bincode::config::WithOtherLimit<bincode::config::DefaultOptions, bincode::config::limit::Infinite>, bincode::config::endian::LittleEndian>, bincode::config::int::VarintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::Options>::deserialize::<surrealdb_core::sql::value::value::Value> Unexecuted instantiation: <_ as bincode::config::Options>::deserialize::<_> |
202 | | |
203 | | /// TODO: document |
204 | | #[doc(hidden)] |
205 | | #[inline(always)] |
206 | 0 | fn deserialize_in_place<'a, R, T>(self, reader: R, place: &mut T) -> Result<()> |
207 | 0 | where |
208 | 0 | R: BincodeRead<'a>, |
209 | 0 | T: serde::de::Deserialize<'a>, |
210 | 0 | { |
211 | 0 | ::internal::deserialize_in_place(reader, self, place) |
212 | 0 | } |
213 | | |
214 | | /// Deserializes a slice of bytes with state `seed` using this configuration. |
215 | | #[inline(always)] |
216 | 0 | fn deserialize_seed<'a, T: serde::de::DeserializeSeed<'a>>( |
217 | 0 | self, |
218 | 0 | seed: T, |
219 | 0 | bytes: &'a [u8], |
220 | 0 | ) -> Result<T::Value> { |
221 | 0 | ::internal::deserialize_seed(seed, bytes, self) |
222 | 0 | } |
223 | | |
224 | | /// Deserializes an object directly from a `Read`er using this configuration |
225 | | /// |
226 | | /// If this returns an `Error`, `reader` may be in an invalid state. |
227 | | #[inline(always)] |
228 | 0 | fn deserialize_from<R: Read, T: serde::de::DeserializeOwned>(self, reader: R) -> Result<T> { |
229 | 0 | ::internal::deserialize_from(reader, self) |
230 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::Options>::deserialize_from::<std::io::cursor::Cursor<alloc::vec::Vec<u8>>, alloc::vec::Vec<u64>> Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::Options>::deserialize_from::<std::io::cursor::Cursor<alloc::vec::Vec<u8>>, std::collections::hash::map::HashMap<surrealdb_core::idx::trees::vector::SharedVector, surrealdb_core::idx::trees::mtree::ObjectProperties, ahash::random_state::RandomState>> Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::Options>::deserialize_from::<std::io::cursor::Cursor<alloc::vec::Vec<u8>>, std::collections::hash::map::HashMap<surrealdb_core::idx::trees::vector::SharedVector, surrealdb_core::idx::trees::mtree::RoutingProperties, ahash::random_state::RandomState>> Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::Options>::deserialize_from::<&mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>, alloc::vec::Vec<u8>> Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::Options>::deserialize_from::<&mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>, u8> Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::Options>::deserialize_from::<&[u8], radix_trie::Trie<alloc::vec::Vec<u8>, u64>> Unexecuted instantiation: <_ as bincode::config::Options>::deserialize_from::<_, _> |
231 | | |
232 | | /// Deserializes an object directly from a `Read`er with state `seed` using this configuration |
233 | | /// |
234 | | /// If this returns an `Error`, `reader` may be in an invalid state. |
235 | | #[inline(always)] |
236 | 0 | fn deserialize_from_seed<'a, R: Read, T: serde::de::DeserializeSeed<'a>>( |
237 | 0 | self, |
238 | 0 | seed: T, |
239 | 0 | reader: R, |
240 | 0 | ) -> Result<T::Value> { |
241 | 0 | ::internal::deserialize_from_seed(seed, reader, self) |
242 | 0 | } |
243 | | |
244 | | /// Deserializes an object from a custom `BincodeRead`er using the default configuration. |
245 | | /// It is highly recommended to use `deserialize_from` unless you need to implement |
246 | | /// `BincodeRead` for performance reasons. |
247 | | /// |
248 | | /// If this returns an `Error`, `reader` may be in an invalid state. |
249 | | #[inline(always)] |
250 | 0 | fn deserialize_from_custom<'a, R: BincodeRead<'a>, T: serde::de::DeserializeOwned>( |
251 | 0 | self, |
252 | 0 | reader: R, |
253 | 0 | ) -> Result<T> { |
254 | 0 | ::internal::deserialize_from_custom(reader, self) |
255 | 0 | } |
256 | | |
257 | | /// Deserializes an object from a custom `BincodeRead`er with state `seed` using the default |
258 | | /// configuration. It is highly recommended to use `deserialize_from` unless you need to |
259 | | /// implement `BincodeRead` for performance reasons. |
260 | | /// |
261 | | /// If this returns an `Error`, `reader` may be in an invalid state. |
262 | | #[inline(always)] |
263 | 0 | fn deserialize_from_custom_seed<'a, R: BincodeRead<'a>, T: serde::de::DeserializeSeed<'a>>( |
264 | 0 | self, |
265 | 0 | seed: T, |
266 | 0 | reader: R, |
267 | 0 | ) -> Result<T::Value> { |
268 | 0 | ::internal::deserialize_from_custom_seed(seed, reader, self) |
269 | 0 | } |
270 | | } |
271 | | |
272 | | impl<T: InternalOptions> Options for T {} |
273 | | |
274 | | /// A configuration struct with a user-specified byte limit |
275 | | #[derive(Clone, Copy)] |
276 | | pub struct WithOtherLimit<O: Options, L: SizeLimit> { |
277 | | _options: O, |
278 | | pub(crate) new_limit: L, |
279 | | } |
280 | | |
281 | | /// A configuration struct with a user-specified endian order |
282 | | #[derive(Clone, Copy)] |
283 | | pub struct WithOtherEndian<O: Options, E: BincodeByteOrder> { |
284 | | options: O, |
285 | | _endian: PhantomData<E>, |
286 | | } |
287 | | |
288 | | /// A configuration struct with a user-specified length encoding |
289 | | #[derive(Clone, Copy)] |
290 | | pub struct WithOtherIntEncoding<O: Options, I: IntEncoding> { |
291 | | options: O, |
292 | | _length: PhantomData<I>, |
293 | | } |
294 | | |
295 | | /// A configuration struct with a user-specified trailing bytes behavior. |
296 | | #[derive(Clone, Copy)] |
297 | | pub struct WithOtherTrailing<O: Options, T: TrailingBytes> { |
298 | | options: O, |
299 | | _trailing: PhantomData<T>, |
300 | | } |
301 | | |
302 | | impl<O: Options, L: SizeLimit> WithOtherLimit<O, L> { |
303 | | #[inline(always)] |
304 | 0 | pub(crate) fn new(options: O, limit: L) -> WithOtherLimit<O, L> { |
305 | 0 | WithOtherLimit { |
306 | 0 | _options: options, |
307 | 0 | new_limit: limit, |
308 | 0 | } |
309 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherLimit<bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::WithOtherEndian<bincode::config::WithOtherLimit<bincode::config::DefaultOptions, bincode::config::limit::Infinite>, bincode::config::endian::LittleEndian>, bincode::config::int::VarintEncoding>, bincode::config::trailing::AllowTrailing>, bincode::config::limit::Infinite>>::new Unexecuted instantiation: <bincode::config::WithOtherLimit<bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing>, bincode::config::limit::Infinite>>::new Unexecuted instantiation: <bincode::config::WithOtherLimit<bincode::config::DefaultOptions, bincode::config::limit::Infinite>>::new Unexecuted instantiation: <bincode::config::WithOtherLimit<_, _>>::new |
310 | | } |
311 | | |
312 | | impl<O: Options, E: BincodeByteOrder> WithOtherEndian<O, E> { |
313 | | #[inline(always)] |
314 | 0 | pub(crate) fn new(options: O) -> WithOtherEndian<O, E> { |
315 | 0 | WithOtherEndian { |
316 | 0 | options, |
317 | 0 | _endian: PhantomData, |
318 | 0 | } |
319 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherEndian<bincode::config::WithOtherLimit<bincode::config::DefaultOptions, bincode::config::limit::Infinite>, bincode::config::endian::LittleEndian>>::new Unexecuted instantiation: <bincode::config::WithOtherEndian<_, _>>::new |
320 | | } |
321 | | |
322 | | impl<O: Options, I: IntEncoding> WithOtherIntEncoding<O, I> { |
323 | | #[inline(always)] |
324 | 0 | pub(crate) fn new(options: O) -> WithOtherIntEncoding<O, I> { |
325 | 0 | WithOtherIntEncoding { |
326 | 0 | options, |
327 | 0 | _length: PhantomData, |
328 | 0 | } |
329 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<bincode::config::WithOtherEndian<bincode::config::WithOtherLimit<bincode::config::DefaultOptions, bincode::config::limit::Infinite>, bincode::config::endian::LittleEndian>, bincode::config::int::VarintEncoding>>::new Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>>::new Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<_, _>>::new |
330 | | } |
331 | | |
332 | | impl<O: Options, T: TrailingBytes> WithOtherTrailing<O, T> { |
333 | | #[inline(always)] |
334 | 0 | pub(crate) fn new(options: O) -> WithOtherTrailing<O, T> { |
335 | 0 | WithOtherTrailing { |
336 | 0 | options, |
337 | 0 | _trailing: PhantomData, |
338 | 0 | } |
339 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::WithOtherEndian<bincode::config::WithOtherLimit<bincode::config::DefaultOptions, bincode::config::limit::Infinite>, bincode::config::endian::LittleEndian>, bincode::config::int::VarintEncoding>, bincode::config::trailing::AllowTrailing>>::new Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing>>::new Unexecuted instantiation: <bincode::config::WithOtherTrailing<_, _>>::new |
340 | | } |
341 | | |
342 | | impl<O: Options, E: BincodeByteOrder + 'static> InternalOptions for WithOtherEndian<O, E> { |
343 | | type Limit = O::Limit; |
344 | | type Endian = E; |
345 | | type IntEncoding = O::IntEncoding; |
346 | | type Trailing = O::Trailing; |
347 | | #[inline(always)] |
348 | 0 | fn limit(&mut self) -> &mut O::Limit { |
349 | 0 | self.options.limit() |
350 | 0 | } |
351 | | } |
352 | | |
353 | | impl<O: Options, L: SizeLimit + 'static> InternalOptions for WithOtherLimit<O, L> { |
354 | | type Limit = L; |
355 | | type Endian = O::Endian; |
356 | | type IntEncoding = O::IntEncoding; |
357 | | type Trailing = O::Trailing; |
358 | 0 | fn limit(&mut self) -> &mut L { |
359 | 0 | &mut self.new_limit |
360 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherLimit<bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::WithOtherEndian<bincode::config::WithOtherLimit<bincode::config::DefaultOptions, bincode::config::limit::Infinite>, bincode::config::endian::LittleEndian>, bincode::config::int::VarintEncoding>, bincode::config::trailing::AllowTrailing>, bincode::config::limit::Infinite> as bincode::config::internal::InternalOptions>::limit Unexecuted instantiation: <bincode::config::WithOtherLimit<bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing>, bincode::config::limit::Infinite> as bincode::config::internal::InternalOptions>::limit Unexecuted instantiation: <bincode::config::WithOtherLimit<_, _> as bincode::config::internal::InternalOptions>::limit |
361 | | } |
362 | | |
363 | | impl<O: Options, I: IntEncoding + 'static> InternalOptions for WithOtherIntEncoding<O, I> { |
364 | | type Limit = O::Limit; |
365 | | type Endian = O::Endian; |
366 | | type IntEncoding = I; |
367 | | type Trailing = O::Trailing; |
368 | | |
369 | 0 | fn limit(&mut self) -> &mut O::Limit { |
370 | 0 | self.options.limit() |
371 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding> as bincode::config::internal::InternalOptions>::limit Unexecuted instantiation: <bincode::config::WithOtherIntEncoding<_, _> as bincode::config::internal::InternalOptions>::limit |
372 | | } |
373 | | |
374 | | impl<O: Options, T: TrailingBytes + 'static> InternalOptions for WithOtherTrailing<O, T> { |
375 | | type Limit = O::Limit; |
376 | | type Endian = O::Endian; |
377 | | type IntEncoding = O::IntEncoding; |
378 | | type Trailing = T; |
379 | | |
380 | 0 | fn limit(&mut self) -> &mut O::Limit { |
381 | 0 | self.options.limit() |
382 | 0 | } Unexecuted instantiation: <bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::internal::InternalOptions>::limit Unexecuted instantiation: <bincode::config::WithOtherTrailing<_, _> as bincode::config::internal::InternalOptions>::limit |
383 | | } |
384 | | |
385 | | mod internal { |
386 | | use super::*; |
387 | | |
388 | | pub trait InternalOptions { |
389 | | type Limit: SizeLimit + 'static; |
390 | | type Endian: BincodeByteOrder + 'static; |
391 | | type IntEncoding: IntEncoding + 'static; |
392 | | type Trailing: TrailingBytes + 'static; |
393 | | |
394 | | fn limit(&mut self) -> &mut Self::Limit; |
395 | | } |
396 | | |
397 | | impl<'a, O: InternalOptions> InternalOptions for &'a mut O { |
398 | | type Limit = O::Limit; |
399 | | type Endian = O::Endian; |
400 | | type IntEncoding = O::IntEncoding; |
401 | | type Trailing = O::Trailing; |
402 | | |
403 | | #[inline(always)] |
404 | 0 | fn limit(&mut self) -> &mut Self::Limit { |
405 | 0 | (*self).limit() |
406 | 0 | } Unexecuted instantiation: <&mut bincode::config::WithOtherLimit<bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing>, bincode::config::limit::Infinite> as bincode::config::internal::InternalOptions>::limit Unexecuted instantiation: <&mut bincode::config::WithOtherTrailing<bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding>, bincode::config::trailing::AllowTrailing> as bincode::config::internal::InternalOptions>::limit Unexecuted instantiation: <&mut bincode::config::WithOtherIntEncoding<bincode::config::DefaultOptions, bincode::config::int::FixintEncoding> as bincode::config::internal::InternalOptions>::limit Unexecuted instantiation: <&mut _ as bincode::config::internal::InternalOptions>::limit |
407 | | } |
408 | | } |