MCPcopy Create free account
hub / github.com/3Hren/msgpack-rust / write_map_len

Function write_map_len

src/encode.rs:725–739  ·  view source on GitHub ↗

Encodes and attempts to write the most efficient map length implementation to the given write, returning the marker used. # Errors This function will return `ValueWriteError` on any I/O error occurred while writing either the marker or the data, except the EINTR, which is handled internally.

(wr: &mut W, len: u32)

Source from the content-addressed store, hash-verified

723/// This function will return `ValueWriteError` on any I/O error occurred while writing either the
724/// marker or the data, except the EINTR, which is handled internally.
725pub fn write_map_len<W>(wr: &mut W, len: u32) -> Result<Marker, ValueWriteError>
726 where W: Write
727{
728 if len < 16 {
729 let marker = Marker::FixMap(len as u8);
730 try!(write_fixval(wr, marker));
731 Ok(marker)
732 } else if len < 65536 {
733 try!(write_marker(wr, Marker::Map16));
734 write_data_u16(wr, len as u16).and(Ok(Marker::Map16))
735 } else {
736 try!(write_marker(wr, Marker::Map32));
737 write_data_u32(wr, len).and(Ok(Marker::Map32))
738 }
739}
740
741/// Encodes and attempts to write the most efficient ext metadata implementation to the given
742/// write, returning the marker used.

Callers 4

write_valueFunction · 0.85
emit_mapMethod · 0.85
visit_mapMethod · 0.85
write_value_refFunction · 0.85

Calls 2

write_fixvalFunction · 0.85
write_markerFunction · 0.85

Tested by

no test coverage detected