Function rmp::encode::write_nfix

source ·
pub fn write_nfix<W: RmpWrite>(wr: &mut W, val: i8) -> Result<(), W::Error>
Expand description

Encodes and attempts to write a negative small integer value as a negative fixnum into the given write.

According to the MessagePack specification, a negative fixed integer value is represented using a single byte in [0xe0; 0xff] range inclusively, prepended with a special marker mask.

The function is strict with the input arguments - it is the user’s responsibility to check if the value fits in the described range, otherwise it will panic.

If you are not sure if the value fits in the given range use write_sint instead, which automatically selects the most compact integer representation.

§Errors

This function will return FixedValueWriteError on any I/O error occurred while writing the positive integer marker.

§Panics

Panics if val does not fit in [-32; 0) range.