MCPcopy Create free account
hub / github.com/apache/thrift / read_bytes

Method read_bytes

lib/rs/src/protocol/compact.rs:267–287  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

265 }
266
267 fn read_bytes(&mut self) -> crate::Result<Vec<u8>> {
268 let len = self.transport.read_varint::<u32>()?;
269
270 if let Some(max_size) = self.config.max_string_size() {
271 if len as usize > max_size {
272 return Err(crate::Error::Protocol(ProtocolError::new(
273 ProtocolErrorKind::SizeLimit,
274 format!(
275 "Byte array size {} exceeds maximum allowed size of {}",
276 len, max_size
277 ),
278 )));
279 }
280 }
281
282 let mut buf = vec![0u8; len as usize];
283 self.transport
284 .read_exact(&mut buf)
285 .map_err(From::from)
286 .map(|_| buf)
287 }
288
289 fn read_i8(&mut self) -> crate::Result<i8> {
290 self.read_byte().map(|i| i as i8)

Callers 1

read_stringMethod · 0.45

Calls 2

max_string_sizeMethod · 0.80
ProtocolClass · 0.50

Tested by

no test coverage detected