-
Notifications
You must be signed in to change notification settings - Fork 0
/
resposereader_internal.go
99 lines (75 loc) · 1.75 KB
/
resposereader_internal.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
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
package finger
import (
"sourcecode.social/reiver/go-utf8"
"fmt"
"io"
"net"
)
var _ ResponseReader = internalResponseReader{}
type internalResponseReader struct {
conn ConnectedReadCloser
}
func (receiver internalResponseReader) Close() error {
var conn ConnectedReadCloser
{
conn = receiver.conn
if nil == conn {
return errNilConnection
}
}
return conn.Close()
}
func (receiver internalResponseReader) LocalAddr() net.Addr {
var conn ConnectedReadCloser
{
conn = receiver.conn
if nil == conn {
return nil
}
}
return conn.LocalAddr()
}
func (receiver internalResponseReader) Read(p []byte) (int, error) {
var conn ConnectedReadCloser
{
conn = receiver.conn
if nil == conn {
return 0, errNilConnection
}
}
return conn.Read(p)
}
func (receiver internalResponseReader) ReadByte() (byte, error) {
var buffer [1]byte
var p []byte = buffer[:]
n, err := receiver.Read(p)
if nil != err {
return 0, fmt.Errorf("problem reading byte from finger-protocol response: %w", err)
}
if expected, actual := 1, n; expected != actual {
return 0, fmt.Errorf("problem reading byte from finger-protocol response: actual number of bytes read is %d but expected it to be %d", actual, expected)
}
return buffer[0], nil
}
func (receiver internalResponseReader) ReadRune() (rune, int, error) {
var conn ConnectedReadCloser
{
conn = receiver.conn
if nil == conn {
return utf8.RuneError, 0, errNilConnection
}
}
var wrapped utf8.RuneReader = utf8.WrapRuneReader(conn)
var runereader io.RuneReader = &wrapped
return runereader.ReadRune()
}
func (receiver internalResponseReader) RemoteAddr() net.Addr {
var conn ConnectedReadCloser
{
conn = receiver.conn
if nil == conn {
return nil
}
}
return conn.RemoteAddr()
}