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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
pub use byteorder::{BigEndian, LittleEndian, ReadBytesExt, WriteBytesExt};
use std::io;
pub trait ReadBytesExtShort: io::Read {
fn read_u16le(&mut self) -> io::Result<u16> {
self.read_u16::<LittleEndian>()
}
fn read_i16le(&mut self) -> io::Result<i16> {
self.read_i16::<LittleEndian>()
}
fn read_u32le(&mut self) -> io::Result<u32> {
self.read_u32::<LittleEndian>()
}
fn read_i32le(&mut self) -> io::Result<i32> {
self.read_i32::<LittleEndian>()
}
fn read_u64le(&mut self) -> io::Result<u64> {
self.read_u64::<LittleEndian>()
}
fn read_i64le(&mut self) -> io::Result<i64> {
self.read_i64::<LittleEndian>()
}
fn read_uintle(&mut self, nbytes: usize) -> io::Result<u64> {
self.read_uint::<LittleEndian>(nbytes)
}
fn read_intle(&mut self, nbytes: usize) -> io::Result<i64> {
self.read_int::<LittleEndian>(nbytes)
}
fn read_f32le(&mut self) -> io::Result<f32> {
self.read_f32::<LittleEndian>()
}
fn read_f64le(&mut self) -> io::Result<f64> {
self.read_f64::<LittleEndian>()
}
fn read_u16be(&mut self) -> io::Result<u16> {
self.read_u16::<BigEndian>()
}
fn read_i16be(&mut self) -> io::Result<i16> {
self.read_i16::<BigEndian>()
}
fn read_u32be(&mut self) -> io::Result<u32> {
self.read_u32::<BigEndian>()
}
fn read_i32be(&mut self) -> io::Result<i32> {
self.read_i32::<BigEndian>()
}
fn read_u64be(&mut self) -> io::Result<u64> {
self.read_u64::<BigEndian>()
}
fn read_i64be(&mut self) -> io::Result<i64> {
self.read_i64::<BigEndian>()
}
fn read_uintbe(&mut self, nbytes: usize) -> io::Result<u64> {
self.read_uint::<BigEndian>(nbytes)
}
fn read_intbe(&mut self, nbytes: usize) -> io::Result<i64> {
self.read_int::<BigEndian>(nbytes)
}
fn read_f32be(&mut self) -> io::Result<f32> {
self.read_f32::<BigEndian>()
}
fn read_f64be(&mut self) -> io::Result<f64> {
self.read_f64::<BigEndian>()
}
}
impl<T> ReadBytesExtShort for T where T: ReadBytesExt {}
pub trait WriteBytesExtShort: WriteBytesExt {
fn write_u16le(&mut self, n: u16) -> io::Result<()> {
self.write_u16::<LittleEndian>(n)
}
fn write_i16le(&mut self, n: i16) -> io::Result<()> {
self.write_i16::<LittleEndian>(n)
}
fn write_u32le(&mut self, n: u32) -> io::Result<()> {
self.write_u32::<LittleEndian>(n)
}
fn write_i32le(&mut self, n: i32) -> io::Result<()> {
self.write_i32::<LittleEndian>(n)
}
fn write_u64le(&mut self, n: u64) -> io::Result<()> {
self.write_u64::<LittleEndian>(n)
}
fn write_i64le(&mut self, n: i64) -> io::Result<()> {
self.write_i64::<LittleEndian>(n)
}
fn write_uintle(&mut self, n: u64, nbytes: usize) -> io::Result<()> {
self.write_uint::<LittleEndian>(n, nbytes)
}
fn write_intle(&mut self, n: i64, nbytes: usize) -> io::Result<()> {
self.write_int::<LittleEndian>(n, nbytes)
}
fn write_f32le(&mut self, n: f32) -> io::Result<()> {
self.write_f32::<LittleEndian>(n)
}
fn write_f64le(&mut self, n: f64) -> io::Result<()> {
self.write_f64::<LittleEndian>(n)
}
fn write_u16be(&mut self, n: u16) -> io::Result<()> {
self.write_u16::<BigEndian>(n)
}
fn write_i16be(&mut self, n: i16) -> io::Result<()> {
self.write_i16::<BigEndian>(n)
}
fn write_u32be(&mut self, n: u32) -> io::Result<()> {
self.write_u32::<BigEndian>(n)
}
fn write_i32be(&mut self, n: i32) -> io::Result<()> {
self.write_i32::<BigEndian>(n)
}
fn write_u64be(&mut self, n: u64) -> io::Result<()> {
self.write_u64::<BigEndian>(n)
}
fn write_i64be(&mut self, n: i64) -> io::Result<()> {
self.write_i64::<BigEndian>(n)
}
fn write_uintbe(&mut self, n: u64, nbytes: usize) -> io::Result<()> {
self.write_uint::<BigEndian>(n, nbytes)
}
fn write_intbe(&mut self, n: i64, nbytes: usize) -> io::Result<()> {
self.write_int::<BigEndian>(n, nbytes)
}
fn write_f32be(&mut self, n: f32) -> io::Result<()> {
self.write_f32::<BigEndian>(n)
}
fn write_f64be(&mut self, n: f64) -> io::Result<()> {
self.write_f64::<BigEndian>(n)
}
}
impl<T> WriteBytesExtShort for T where T: WriteBytesExt {}