MCPcopy Create free account
hub / github.com/LibertyOS-Development/kernel / frombytes

Function frombytes

src/font.rs:14–42  ·  view source on GitHub ↗
(buf: &[u8])

Source from the content-addressed store, hash-verified

12
13
14pub fn frombytes(buf: &[u8]) -> Result<Font, ()>
15{
16 if buf.len() < 4 || buf[0] != 0x36 || buf[1] != 0x04
17 {
18 return Err(());
19 }
20 let mode = buf[2];
21 let h = buf[3];
22 let sz = match mode
23 {
24 0 | 2 => 256,
25 1 | 3 => 512,
26 _ => return Err(()),
27 };
28
29 let n = (4 + sz * h as u16) as usize;
30 if buf.len() < n
31 {
32 return Err(());
33 }
34 let dat = buf[4..n].to_vec();
35
36 Ok(Font
37 {
38 h,
39 sz,
40 dat
41 })
42}

Callers

nothing calls this directly

Calls 2

ErrEnum · 0.70
lenMethod · 0.45

Tested by

no test coverage detected