pub struct DeserializationConfig { /* private fields */ }Expand description
A configuration used to Serialize TFHE-rs objects. This configuration decides the various sanity checks that will be performed during deserialization.
Implementations§
Source§impl DeserializationConfig
impl DeserializationConfig
Sourcepub fn new(deserialized_size_limit: u64) -> Self
pub fn new(deserialized_size_limit: u64) -> Self
Creates a new deserialization config.
By default, it will check that the serialization version and the name of the
deserialized type are correct.
deserialized_size_limit is the size limit (in number of bytes) of the deserialized object.
It should be set according to the expected size of the object and the maximum allocatable
size on your system.
It will also check that the object is conformant with the parameter set given in
conformance_params. Finally, it will check the compatibility of the loaded data with
the current TFHE-rs version.
Sourcepub fn new_with_unlimited_size() -> Self
pub fn new_with_unlimited_size() -> Self
Creates a new config without any size limit for the deserialized objects.
Sourcepub fn disable_size_limit(self) -> Self
pub fn disable_size_limit(self) -> Self
Disables the size limit for the serialized objects.
Sourcepub fn with_size_limit(self, size: u64) -> Self
pub fn with_size_limit(self, size: u64) -> Self
Sets the size limit for this deserialization config
Sourcepub fn disable_header_validation(self) -> Self
pub fn disable_header_validation(self) -> Self
Disables the header validation on the object. This header validations checks that the serialized object is the one that is supposed to be loaded and is compatible with this version of TFHE-rs.
Sourcepub fn disable_conformance(self) -> NonConformantDeserializationConfig
pub fn disable_conformance(self) -> NonConformantDeserializationConfig
Disables the conformance check on an existing config.
Sourcepub fn deserialize_from<T: DeserializeOwned + Unversionize + Named + ParameterSetConformant>(
self,
reader: impl Read,
parameter_set: &T::ParameterSet,
) -> Result<T, String>
pub fn deserialize_from<T: DeserializeOwned + Unversionize + Named + ParameterSetConformant>( self, reader: impl Read, parameter_set: &T::ParameterSet, ) -> Result<T, String>
Deserializes an object serialized by SerializationConfig::serialize_into from a
reader. Performs various sanity checks based on the deserialization config.
§Panics
This function may panic if serialized_size_limit is larger than what can be allocated by
the system. This may happen even if the size of the serialized data is short. An
attacker could manipulate the data to create a short serialized message with a huge
deserialized size.
Trait Implementations§
Source§impl Clone for DeserializationConfig
impl Clone for DeserializationConfig
Source§fn clone(&self) -> DeserializationConfig
fn clone(&self) -> DeserializationConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for DeserializationConfig
Auto Trait Implementations§
impl Freeze for DeserializationConfig
impl RefUnwindSafe for DeserializationConfig
impl Send for DeserializationConfig
impl Sync for DeserializationConfig
impl Unpin for DeserializationConfig
impl UnwindSafe for DeserializationConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more