Encodes and attempts to write an `i64` value into the given write using the most efficient representation, returning the marker used. This function obeys the MessagePack specification, which requires that the serializer SHOULD use the format which represents the data in the smallest number of bytes, with the exception of sized/unsized types. Note, that the function will **always** use signed int
(wr: &mut W, val: i64)
| 517 | /// This function will return `ValueWriteError` on any I/O error occurred while writing either the |
| 518 | /// marker or the data, except the EINTR, which is handled internally. |
| 519 | pub fn write_sint<W>(wr: &mut W, val: i64) -> Result<Marker, ValueWriteError> |
| 520 | where W: Write |
| 521 | { |
| 522 | if -32 <= val && val <= 0 { |
| 523 | let marker = Marker::FixNeg(val as i8); |
| 524 | |
| 525 | try!(write_fixval(wr, marker)); |
| 526 | |
| 527 | Ok(marker) |
| 528 | } else if -128 <= val && val < 128 { |
| 529 | write_i8(wr, val as i8).and(Ok(Marker::I8)) |
| 530 | } else if -32768 <= val && val < 32768 { |
| 531 | write_i16(wr, val as i16).and(Ok(Marker::I16)) |
| 532 | } else if -2147483648 <= val && val <= 2147483647 { |
| 533 | write_i32(wr, val as i32).and(Ok(Marker::I32)) |
| 534 | } else { |
| 535 | write_i64(wr, val).and(Ok(Marker::I64)) |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | /// Encodes and attempts to write an `i64` value using the most effective representation. |
| 540 | fn write_sint_eff<W>(wr: &mut W, val: i64) -> Result<Marker, ValueWriteError> |
no test coverage detected