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)
| 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. |
| 666 | pub 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 | /// |
no test coverage detected