Skip to main content

read_float

Function read_float 

Source
pub fn read_float(data: &[u8]) -> Result<Consumed<f32>>
Expand description

Read a single-precision float (f32) from the byte stream.

Prefixed by DECIMAL for a raw f32, or coerced from integer tags.

§Errors

Returns TypedStreamError::OutOfBounds if the underlying byte slice is too short.

§Examples

use crabstep::deserializer::number::read_float;

let raw = [0x83, 0x00, 0x00, 0x80, 0x3F]; // DECIMAL tag + little-endian 1.0f32
let consumed = read_float(&raw).unwrap();

assert_eq!(consumed.value, 1.0f32);