pub struct DeserializerConfig { /* private fields */ }Expand description
Configures how pickles are deserialized.
The configuration is independent of the input so it can be created once
(even as a constant) and used for many inputs. The method
from_slice works like the function of the same
name.
use deser_pickle::DeserializerConfig;
const CONFIG: DeserializerConfig = DeserializerConfig::new();
// `pickle.dumps([1, 2], 4)`
let input = b"\x80\x04\x95\x09\x00\x00\x00\x00\x00\x00\x00]\x94(K\x01K\x02e.";
assert_eq!(CONFIG.from_slice::<Vec<u32>>(input).unwrap(), [1, 2]);Implementations§
Source§impl DeserializerConfig
impl DeserializerConfig
Sourcepub const fn new() -> DeserializerConfig
pub const fn new() -> DeserializerConfig
Creates the default configuration.
Sourcepub const fn builder() -> DeserializerConfigBuilder
pub const fn builder() -> DeserializerConfigBuilder
Returns a builder for the configuration (see DeserializerConfigBuilder).
Sourcepub const fn into_builder(self) -> DeserializerConfigBuilder
pub const fn into_builder(self) -> DeserializerConfigBuilder
Returns a builder that starts with this configuration.
Sourcepub fn set_context(&mut self, context: Context)
pub fn set_context(&mut self, context: Context)
Sets the context the values are deserialized in.
The values of the context are the defaults of the extension values
of the state (see Context), for instance
the variants of open enums. The deserializers and readers created
with the configuration use this context. A context set on the
driver takes precedence.
Limits the events of values that are emitted more than once.
Values that are reached more than once are emitted at every place (see References). A small pickle can reach the same values very often (each level of a list that holds the level below twice doubles the output), this limits the number of events that are emitted for values that were emitted before. The default is 1048576.
Returns the limit of the events of values that are emitted more than once.
Sourcepub fn from_slice<'de, T: Deserialize<'de>>(
&self,
input: &'de [u8],
) -> Result<T, Error>
pub fn from_slice<'de, T: Deserialize<'de>>( &self, input: &'de [u8], ) -> Result<T, Error>
Deserializes a value.
See from_slice.
Source§impl DeserializerConfig
impl DeserializerConfig
Sourcepub fn reader<R: Read>(&self, reader: R) -> Reader<R, StreamDeserializer>
pub fn reader<R: Read>(&self, reader: R) -> Reader<R, StreamDeserializer>
Creates a reader of values (see
deser::io::Reader).
See StreamDeserializer.
Sourcepub fn from_reader<T: DeserializeOwned, R: Read>(
&self,
reader: R,
) -> Result<T, Error>
pub fn from_reader<T: DeserializeOwned, R: Read>( &self, reader: R, ) -> Result<T, Error>
Deserializes a value from a reader.
See from_reader.