1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use Read;
use Result;
use Write;
/// Read `u64` from the LEB128+ format.
///
/// Examples
///
/// ```
/// let mut c = std::io::Cursor::new(&[
/// 0,
/// 127,
/// 128, 0,
/// 0xFF, 0,
/// 0xFF, 1,
/// 0xFF, 0x7F,
/// 0x80, 0x80, 0,
/// 128,
/// ]);
/// assert_eq!(leb128plus::read(&mut c).unwrap(), 0);
/// assert_eq!(leb128plus::read(&mut c).unwrap(), 127);
/// assert_eq!(leb128plus::read(&mut c).unwrap(), 128);
/// assert_eq!(leb128plus::read(&mut c).unwrap(), 0xFF);
/// assert_eq!(leb128plus::read(&mut c).unwrap(), 0x17F);
/// assert_eq!(leb128plus::read(&mut c).unwrap(), 0x407F);
/// assert_eq!(leb128plus::read(&mut c).unwrap(), 0x4080);
/// assert!(match leb128plus::read(&mut c) {
/// Result::Err(_) => true,
/// _ => false
/// });
/// ```
/// Write `u64` in the LEB128+ format.
///
/// Examples
///
/// ```
/// let mut v = vec![];
/// {
/// let mut c = std::io::Cursor::new(&mut v);
/// leb128plus::write(&mut c, 0);
/// leb128plus::write(&mut c, 127);
/// leb128plus::write(&mut c, 128);
/// leb128plus::write(&mut c, 0xFF);
/// leb128plus::write(&mut c, 0x17F);
/// leb128plus::write(&mut c, 0x407F);
/// leb128plus::write(&mut c, 0x4080);
/// }
/// assert_eq!(v, [
/// 0,
/// 127,
/// 128, 0,
/// 0xFF, 0,
/// 0xFF, 1,
/// 0xFF, 0x7F,
/// 0x80, 0x80, 0x00
/// ]);
/// ```