Encodes and attempts to write an `u64` 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. The first byte becomes the marker and the others (if present, up to 9) will represent the data it
(wr: &mut W, val: u64)
| 480 | /// marker or the data, except the EINTR, which is handled internally. |
| 481 | // TODO: Replace with `match`? |
| 482 | pub fn write_uint<W>(wr: &mut W, val: u64) -> Result<Marker, ValueWriteError> |
| 483 | where W: Write |
| 484 | { |
| 485 | if val < 128 { |
| 486 | let marker = Marker::FixPos(val as u8); |
| 487 | |
| 488 | try!(write_fixval(wr, marker)); |
| 489 | |
| 490 | Ok(marker) |
| 491 | } else if val < 256 { |
| 492 | write_u8(wr, val as u8).and(Ok(Marker::U8)) |
| 493 | } else if val < 65536 { |
| 494 | write_u16(wr, val as u16).and(Ok(Marker::U16)) |
| 495 | } else if val < 4294967296 { |
| 496 | write_u32(wr, val as u32).and(Ok(Marker::U32)) |
| 497 | } else { |
| 498 | write_u64(wr, val).and(Ok(Marker::U64)) |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | /// Encodes and attempts to write an `i64` value into the given write using the most efficient |
| 503 | /// representation, returning the marker used. |
no test coverage detected