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

Function write_bin_len

src/encode.rs:666–679  ·  view source on GitHub ↗

Encodes and attempts to write the most efficient binary array length implementation to the given write, returning the marker used. This function is useful when you want to get full control for writing the data itself, for example, when using non-blocking socket. # Errors This function will return `ValueWriteError` on any I/O error occurred while writing either the marker or the data, except the

(wr: &mut W, len: u32)

Source from the content-addressed store, hash-verified

664/// This function will return `ValueWriteError` on any I/O error occurred while writing either the
665/// marker or the data, except the EINTR, which is handled internally.
666pub fn write_bin_len<W>(wr: &mut W, len: u32) -> Result<Marker, ValueWriteError>
667 where W: Write
668{
669 if len < 256 {
670 try!(write_marker(wr, Marker::Bin8));
671 write_data_u8(wr, len as u8).and(Ok(Marker::Bin8))
672 } else if len < 65536 {
673 try!(write_marker(wr, Marker::Bin16));
674 write_data_u16(wr, len as u16).and(Ok(Marker::Bin16))
675 } else {
676 try!(write_marker(wr, Marker::Bin32));
677 write_data_u32(wr, len).and(Ok(Marker::Bin32))
678 }
679}
680
681/// Encodes and attempts to write the most efficient binary implementation to the given `Write`.
682///

Callers 2

write_binFunction · 0.85
visit_bytesMethod · 0.85

Calls 1

write_markerFunction · 0.85

Tested by

no test coverage detected