Debian Codegraph @

multi.go

raw symbols SCIP
1 package bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/
2
3 import (
4 "bytesscip-go gomod github.com/golang/go/src go1.13 bytes/"
5 "encoding/gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/"
6 "ioscip-go gomod github.com/golang/go/src go1.13 io/"
7 "mathscip-go gomod github.com/golang/go/src go1.13 math/"
8 )
9
10 type chainscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain# struct {
11 Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf. BufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAt#
12 Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next. BufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAt#
13 }
14
15 type nopBufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/nopBufferAt# struct {
16 Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/nopBufferAt#Buffer.
17 }
18
19 func (buf *nopBufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/nopBufferAt#) ReadAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/nopBufferAt#ReadAt().(p []byte, off int64) (int, error) {
20 panic("ReadAt not implemented")
21 }
22
23 func (buf *nopBufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/nopBufferAt#) WriteAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/nopBufferAt#WriteAt().(p []byte, off int64) (int, error) {
24 panic("WriteAt not implemented")
25 }
26
27 // toBufferAt converts a Buffer to a BufferAt with nop ReadAt and WriteAt funcs
28 func toBufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/toBufferAt().(buf Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#) BufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAt# {
29 return &nopBufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/nopBufferAt#{Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/nopBufferAt#Buffer.: buf}
30 }
31
32 // NewMultiAt returns a BufferAt which is the logical concatenation of the passed BufferAts.
33 // The data in the buffers is shifted such that there is no non-empty buffer following
34 // a non-full buffer, this process is also run after every Read.
35 // If no buffers are passed, the returned Buffer is nil.
36 func NewMultiAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMultiAt().(buffers ...BufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAt#) BufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAt# {
37 if len(buffers) == 0 {
38 return nil
39 } else if len(buffers) == 1 {
40 return buffers[0]
41 }
42
43 buf := &chainscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#{
44 Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf.: buffers[0],
45 Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next.: NewMultiAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMultiAt().(buffers[1:]...),
46 }
47
48 buf.Defragscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Defrag().()
49
50 return buf
51 }
52
53 // NewMulti returns a Buffer which is the logical concatenation of the passed buffers.
54 // The data in the buffers is shifted such that there is no non-empty buffer following
55 // a non-full buffer, this process is also run after every Read.
56 // If no buffers are passed, the returned Buffer is nil.
57 func NewMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMulti().(buffers ...Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#) Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer# {
58 bufAt := make([]BufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAt#, len(buffers))
59 for i, buf := range buffers {
60 bufAt[i] = toBufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/toBufferAt().(buf)
61 }
62 return NewMultiAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMultiAt().(bufAt...)
63 }
64
65 func (buf *chainscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#) Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Reset().() {
66 buf.Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next..Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Reset.()
67 buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Reset.()
68 }
69
70 func (buf *chainscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#) Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Cap().() (n int64) {
71 Next := buf.Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next..Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.()
72 if buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() > mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64.-Next {
73 return mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64.
74 }
75 return buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() + Next
76 }
77
78 func (buf *chainscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#) Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Len().() (n int64) {
79 Next := buf.Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next..Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.()
80 if buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() > mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64.-Next {
81 return mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64.
82 }
83 return buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() + Next
84 }
85
86 func (buf *chainscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#) Defragscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Defrag().() {
87 for !Fullscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Full().(buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf.) && !Emptyscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Empty().(buf.Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next.) {
88 r := ioscip-go gomod github.com/golang/go/src go1.13 io/.LimitReaderscip-go gomod github.com/golang/go/src go1.13 io/LimitReader().(buf.Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next., Gapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Gap().(buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf.))
89 if _, err := ioscip-go gomod github.com/golang/go/src go1.13 io/.Copyscip-go gomod github.com/golang/go/src go1.13 io/Copy().(buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf., r); err != nil && err != ioscip-go gomod github.com/golang/go/src go1.13 io/.EOFscip-go gomod github.com/golang/go/src go1.13 io/EOF. {
90 return
91 }
92 }
93 }
94
95 func (buf *chainscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#) Readscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Read().(p []byte) (n int, err error) {
96 n, err = buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(p)
97 if len(p[n:]) > 0 && (err == nil || err == ioscip-go gomod github.com/golang/go/src go1.13 io/.EOFscip-go gomod github.com/golang/go/src go1.13 io/EOF.) {
98 m, err := buf.Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next..Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(p[n:])
99 n += m
100 if err != nil {
101 return n, err
102 }
103 }
104
105 buf.Defragscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Defrag().()
106
107 return n, err
108 }
109
110 func (buf *chainscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#) ReadAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#ReadAt().(p []byte, off int64) (n int, err error) {
111 if buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() < off {
112 return buf.Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next..ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(p, off-buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.())
113 }
114
115 n, err = buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(p, off)
116 if len(p[n:]) > 0 && (err == nil || err == ioscip-go gomod github.com/golang/go/src go1.13 io/.EOFscip-go gomod github.com/golang/go/src go1.13 io/EOF.) {
117 var m int
118 m, err = buf.Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next..ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(p[n:], 0)
119 n += m
120 }
121 return n, err
122 }
123
124 func (buf *chainscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#) Writescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Write().(p []byte) (n int, err error) {
125 if n, err = buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().(p); err == ioscip-go gomod github.com/golang/go/src go1.13 io/.ErrShortWritescip-go gomod github.com/golang/go/src go1.13 io/ErrShortWrite. {
126 err = nil
127 }
128 p = p[n:]
129 if len(p) > 0 && err == nil {
130 m, err := buf.Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next..Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().(p)
131 n += m
132 if err != nil {
133 return n, err
134 }
135 }
136 return n, err
137 }
138
139 func (buf *chainscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#) WriteAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#WriteAt().(p []byte, off int64) (n int, err error) {
140 switch {
141 case buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() <= off: // past the end
142 return buf.Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next..WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().(p, off-buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.())
143
144 case buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() >= off+int64(len(p)): // fits in
145 return buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().(p, off)
146
147 default: // partial fit
148 n, err = buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf..WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().(p, off)
149 if len(p[n:]) > 0 && (err == nil || err == ioscip-go gomod github.com/golang/go/src go1.13 io/.ErrShortWritescip-go gomod github.com/golang/go/src go1.13 io/ErrShortWrite.) {
150 var m int
151 m, err = buf.Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next..WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().(p[n:], 0)
152 n += m
153 }
154 return n, err
155 }
156 }
157
158 func initscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/init().() {
159 gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.Registerscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Register().(&chainscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#{})
160 gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.Registerscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Register().(&nopBufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/nopBufferAt#{})
161 }
162
163 func (buf *chainscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#) MarshalBinaryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#MarshalBinary().() ([]byte, error) {
164 b := bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.13 bytes/NewBuffer().(nil)
165 enc := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewEncoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewEncoder().(b)
166 if err := enc.Encodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Encoder#Encode().(&buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf.); err != nil {
167 return nil, err
168 }
169 if err := enc.Encodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Encoder#Encode().(&buf.Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next.); err != nil {
170 return nil, err
171 }
172 return b.Bytesscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#Bytes().(), nil
173 }
174
175 func (buf *chainscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#) UnmarshalBinaryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#UnmarshalBinary().(data []byte) error {
176 b := bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.13 bytes/NewBuffer().(data)
177 dec := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewDecoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewDecoder().(b)
178 if err := dec.Decodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Decoder#Decode().(&buf.Bufscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Buf.); err != nil {
179 return err
180 }
181 if err := dec.Decodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Decoder#Decode().(&buf.Nextscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/chain#Next.); err != nil {
182 return err
183 }
184 return nil
185 }