-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbytes.go
53 lines (39 loc) · 1.18 KB
/
bytes.go
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
package byteio
// ReadByte implements the io.ByteReader interface.
func (e *BigEndianReader) ReadByte() (byte, error) {
b, _, err := e.ReadUint8()
return b, err
}
// WriteByte implements the io.ByteWriter interface.
func (e *BigEndianWriter) WriteByte(c byte) error {
_, err := e.WriteUint8(c)
return err
}
// ReadByte implements the io.ByteReader interface.
func (e *LittleEndianReader) ReadByte() (byte, error) {
b, _, err := e.ReadUint8()
return b, err
}
// WriteByte implements the io.ByteWriter interface.
func (e *LittleEndianWriter) WriteByte(c byte) error {
_, err := e.WriteUint8(c)
return err
}
// ReadByte implements the io.ByteReader interface.
func (e *StickyBigEndianReader) ReadByte() (byte, error) {
return e.ReadUint8(), e.Err
}
// WriteByte implements the io.ByteWriter interface.
func (e *StickyBigEndianWriter) WriteByte(c byte) error {
e.WriteUint8(c)
return e.Err
}
// ReadByte implements the io.ByteReader interface.
func (e *StickyLittleEndianReader) ReadByte() (byte, error) {
return e.ReadUint8(), e.Err
}
// WriteByte implements the io.ByteWriter interface.
func (e *StickyLittleEndianWriter) WriteByte(c byte) error {
e.WriteUint8(c)
return e.Err
}