Debian Codegraph @

proto/frame/wndinc.go

raw
1 package frame
2
3 import "io"
4
5 const (
6 wndIncBodySize = 4
7 wndIncFrameSize = headerSize + wndIncBodySize
8 )
9
10 // Increase a stream's flow control window size
11 type RStreamWndInc struct {
12 Header
13 body [wndIncBodySize]byte
14 }
15
16 func (f *RStreamWndInc) WindowIncrement() (inc uint32) {
17 return order.Uint32(f.body[:]) & wndIncMask
18 }
19
20 func (f *RStreamWndInc) readFrom(d deserializer) (err error) {
21 if f.Length() != wndIncBodySize {
22 return protoError("WND_INC length must be %d, got %d", wndIncBodySize, f.Length())
23 }
24
25 _, err = io.ReadFull(d, f.body[:])
26 return
27 }
28
29 type WStreamWndInc struct {
30 Header
31 data [wndIncFrameSize]byte
32 }
33
34 func (f *WStreamWndInc) writeTo(s serializer) (err error) {
35 _, err = s.Write(f.data[:])
36 return
37 }
38
39 func (f *WStreamWndInc) Set(streamId StreamId, inc uint32) (err error) {
40 if inc > wndIncMask {
41 return protoError("Window increment %d out of range", inc)
42 }
43
44 order.PutUint32(f.data[headerSize:], inc)
45
46 if err = f.Header.SetAll(TypeStreamWndInc, wndIncBodySize, streamId, 0); err != nil {
47 return
48 }
49
50 return
51 }
52
53 func NewWStreamWndInc() (f *WStreamWndInc) {
54 f = new(WStreamWndInc)
55 f.Header = Header(f.data[:headerSize])
56 return
57 }