Function rmp::decode::read_u64_loosely
[−]
[src]
pub fn read_u64_loosely<R>(rd: &mut R) -> Result<u64, ValueReadError> where R: Read
Attempts to read up to 9 bytes from the given reader and to decode them as u64
value.
This function will try to read up to 9 bytes from the reader (1 for marker and up to 8 for data) and interpret them as a big-endian u64.
Unlike the read_u64
, this function weakens type restrictions, allowing you to safely decode
packed values even if you aren't sure about the actual type.
Note, that trying to decode signed integers will result in TypeMismatch
error even if the
value fits in u64
.
Errors
This function will return ValueReadError
on any I/O error while reading either the marker or
the data, except the EINTR, which is handled internally.
It also returns ValueReadError::TypeMismatch
if the actual type is not equal with the
expected one, indicating you with the actual type.
Note
This function will silently retry on every EINTR received from the underlying Read
until
successful read.