useself::EndianOption::*; useself::LimitOption::*; usesuper::{DefaultOptions, Options}; use de::read::BincodeRead; use error::Result; use serde;
/// A configuration builder whose options Bincode will use /// while serializing and deserializing. /// /// ### Options /// Endianness: The endianness with which multi-byte integers will be read/written. *default: little endian* /// Limit: The maximum number of bytes that will be read/written in a bincode serialize/deserialize. *default: unlimited* /// /// ### Byte Limit Details /// The purpose of byte-limiting is to prevent Denial-Of-Service attacks whereby malicious attackers get bincode /// deserialization to crash your process by allocating too much memory or keeping a connection open for too long. /// /// When a byte limit is set, bincode will return `Err` on any deserialization that goes over the limit, or any /// serialization that goes over the limit. #[derive(Clone, Debug)] #[deprecated(
since = "1.3.0",
note = "please use the `DefaultOptions`/`Options` system instead"
)] pubstruct Config {
limit: LimitOption,
endian: EndianOption,
}
/// Sets the byte limit to be unlimited. /// This is the default. #[inline(always)] pubfn no_limit(&mutself) -> &mutSelf { self.limit = LimitOption::Unlimited; self
}
/// Sets the byte limit to `limit`. #[inline(always)] pubfn limit(&mutself, limit: u64) -> &mutSelf { self.limit = LimitOption::Limited(limit); self
}
/// Sets the endianness to little-endian /// This is the default. #[inline(always)] pubfn little_endian(&mutself) -> &mutSelf { self.endian = EndianOption::Little; self
}
/// Sets the endianness to big-endian #[inline(always)] pubfn big_endian(&mutself) -> &mutSelf { self.endian = EndianOption::Big; self
}
/// Sets the endianness to the the machine-native endianness #[inline(always)] pubfn native_endian(&mutself) -> &mutSelf { self.endian = EndianOption::Native; self
}
/// Serializes a serializable object into a `Vec` of bytes using this configuration #[inline(always)] pubfn serialize<T: ?Sized + serde::Serialize>(&self, t: &T) -> Result<Vec<u8>> {
config_map!(self, opts => ::internal::serialize(t, opts))
}
/// Returns the size that an object would be if serialized using Bincode with this configuration #[inline(always)] pubfn serialized_size<T: ?Sized + serde::Serialize>(&self, t: &T) -> Result<u64> {
config_map!(self, opts => ::internal::serialized_size(t, opts))
}
/// Serializes an object directly into a `Writer` using this configuration /// /// If the serialization would take more bytes than allowed by the size limit, an error /// is returned and *no bytes* will be written into the `Writer` #[inline(always)] pubfn serialize_into<W: Write, T: ?Sized + serde::Serialize>(
&self,
w: W,
t: &T,
) -> Result<()> {
config_map!(self, opts => ::internal::serialize_into(w, t, opts))
}
/// Deserializes a slice of bytes into an instance of `T` using this configuration #[inline(always)] pubfn deserialize<'a, T: serde::Deserialize<'a>>(&self, bytes: & style='color:blue'>'a [u8]) -> Result<T> {
config_map!(self, opts => ::internal::deserialize(bytes, opts))
}
/// Deserializes a slice of bytes with state `seed` using this configuration. #[inline(always)] pubfn deserialize_seed<'a, T: serde::de::DeserializeSeed<'a>>(
&self,
seed: T,
bytes: &'a [u8],
) -> Result<T::Value> {
config_map!(self, opts => ::internal::deserialize_seed(seed, bytes, opts))
}
/// Deserializes an object directly from a `Read`er using this configuration /// /// If this returns an `Error`, `reader` may be in an invalid state. #[inline(always)] pubfn deserialize_from<R: Read, T: serde::de::DeserializeOwned>(
&self,
reader: R,
) -> Result<T> {
config_map!(self, opts => ::internal::deserialize_from(reader, opts))
}
/// Deserializes an object directly from a `Read`er with state `seed` using this configuration /// /// If this returns an `Error`, `reader` may be in an invalid state. #[inline(always)] pubfn deserialize_from_seed<'a, R: Read, T: serde::de::DeserializeSeed<'a>>(
&self,
seed: T,
reader: R,
) -> Result<T::Value> {
config_map!(self, opts => ::internal::deserialize_from_seed(seed, reader, opts))
}
/// Deserializes an object from a custom `BincodeRead`er using the default configuration. /// It is highly recommended to use `deserialize_from` unless you need to implement /// `BincodeRead` for performance reasons. /// /// If this returns an `Error`, `reader` may be in an invalid state. #[inline(always)] pubfn deserialize_from_custom<'a, R: BincodeRead<'a>, T: serde::de::DeserializeOwned>(
&self,
reader: R,
) -> Result<T> {
config_map!(self, opts => ::internal::deserialize_from_custom(reader, opts))
}
/// Deserializes an object from a custom `BincodeRead`er with state `seed` using the default /// configuration. It is highly recommended to use `deserialize_from` unless you need to /// implement `BincodeRead` for performance reasons. /// /// If this returns an `Error`, `reader` may be in an invalid state. #[inline(always)] pubfn deserialize_from_custom_seed< 'a,
R: BincodeRead<'a>,
T: serde::de::DeserializeSeed<'a>,
>(
&self,
seed: T,
reader: R,
) -> Result<T::Value> {
config_map!(self, opts => ::internal::deserialize_from_custom_seed(seed, reader, opts))
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.18 Sekunden
(vorverarbeitet am 2026-06-19)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.