MCPcopy Create free account
hub / github.com/Lokathor/tinyvec / deserialize_reader

Method deserialize_reader

src/arrayvec.rs:240–261  ·  view source on GitHub ↗
(
    reader: &mut R,
  )

Source from the content-addressed store, hash-verified

238 <A as Array>::Item: borsh::BorshDeserialize,
239{
240 fn deserialize_reader<R: borsh::io::Read>(
241 reader: &mut R,
242 ) -> borsh::io::Result<Self> {
243 let len = <usize as borsh::BorshDeserialize>::deserialize_reader(reader)?;
244 let mut new_arrayvec = Self::default();
245
246 for idx in 0..len {
247 let value =
248 <<A as Array>::Item as borsh::BorshDeserialize>::deserialize_reader(
249 reader,
250 )?;
251 if idx >= new_arrayvec.capacity() {
252 return Err(borsh::io::Error::new(
253 borsh::io::ErrorKind::InvalidData,
254 "invalid ArrayVec length",
255 ));
256 }
257 new_arrayvec.push(value)
258 }
259
260 Ok(new_arrayvec)
261 }
262}
263
264#[cfg(feature = "arbitrary")]

Callers

nothing calls this directly

Calls 2

capacityMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected