MCPcopy Create free account
hub / github.com/RustCrypto/formats / tls_deserialize

Method tls_deserialize

tls_codec/src/primitives.rs:52–65  ·  view source on GitHub ↗
(bytes: &mut R)

Source from the content-addressed store, hash-verified

50 #[cfg(feature = "std")]
51 #[inline]
52 fn tls_deserialize<R: Read>(bytes: &mut R) -> Result<Self, Error> {
53 let mut some_or_none = [0u8; 1];
54 bytes.read_exact(&mut some_or_none)?;
55 match some_or_none[0] {
56 0 => {
57 Ok(None)
58 },
59 1 => {
60 let element = T::tls_deserialize(bytes)?;
61 Ok(Some(element))
62 },
63 _ => Err(Error::DecodingError(format!("Trying to decode Option<T> with {} for option. It must be 0 for None and 1 for Some.", some_or_none[0])))
64 }
65 }
66}
67
68macro_rules! impl_unsigned {

Callers

nothing calls this directly

Calls 2

tls_deserializeFunction · 0.85
read_exactMethod · 0.45

Tested by

no test coverage detected