Function rmp::encode::write_u16 [] [src]

pub fn write_u16<W: Write>(wr: &mut W, val: u16) -> Result<(), ValueWriteError>

Encodes and attempts to write an u16 value strictly as a 3-byte sequence into the given write.

The first byte becomes the marker and the others will represent the data itself.

Note, that this function will encode the given value in 3-byte sequence no matter what, even if the value can be represented using single byte as a positive fixnum.

If you need to fit the given buffer efficiently use write_uint instead, which automatically selects the appropriate integer representation.

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.