MCPcopy Create free account
hub / github.com/RustCrypto/utils / deserialize

Method deserialize

block-buffer/src/read.rs:170–178  ·  view source on GitHub ↗
(buffer: &Array<u8, BS>)

Source from the content-addressed store, hash-verified

168 /// - If the first byte is bigger than `BS`.
169 #[inline]
170 pub fn deserialize(buffer: &Array<u8, BS>) -> Result<Self, Error> {
171 let pos = usize::from(buffer[0]);
172 if pos == 0 || pos > BS::USIZE || buffer[1..pos].iter().any(|&b| b != 0) {
173 Err(Error)
174 } else {
175 let buffer = buffer.clone();
176 Ok(Self { buffer })
177 }
178 }
179}
180
181#[cfg(feature = "zeroize")]

Callers

nothing calls this directly

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected