vu128

Function encode_f32

Source
pub fn encode_f32(buf: &mut [u8; 5], value: f32) -> usize
Expand description

Encodes an f32 into a buffer, returning the encoded length.

The contents of the buffer beyond the returned length are unspecified.

ยงExamples

let mut buf = [0u8; 5];
let encoded_len = vu128::encode_f32(&mut buf, 2.5);
assert_eq!(&buf[..encoded_len], &[0x80, 0x81]);