github.com/quic-go/quic-go@v0.44.0/internal/wire/stream_data_blocked_frame.go (about) 1 package wire 2 3 import ( 4 "github.com/quic-go/quic-go/internal/protocol" 5 "github.com/quic-go/quic-go/quicvarint" 6 ) 7 8 // A StreamDataBlockedFrame is a STREAM_DATA_BLOCKED frame 9 type StreamDataBlockedFrame struct { 10 StreamID protocol.StreamID 11 MaximumStreamData protocol.ByteCount 12 } 13 14 func parseStreamDataBlockedFrame(b []byte, _ protocol.Version) (*StreamDataBlockedFrame, int, error) { 15 startLen := len(b) 16 sid, l, err := quicvarint.Parse(b) 17 if err != nil { 18 return nil, 0, replaceUnexpectedEOF(err) 19 } 20 b = b[l:] 21 offset, l, err := quicvarint.Parse(b) 22 if err != nil { 23 return nil, 0, replaceUnexpectedEOF(err) 24 } 25 26 return &StreamDataBlockedFrame{ 27 StreamID: protocol.StreamID(sid), 28 MaximumStreamData: protocol.ByteCount(offset), 29 }, startLen - len(b) + l, nil 30 } 31 32 func (f *StreamDataBlockedFrame) Append(b []byte, _ protocol.Version) ([]byte, error) { 33 b = append(b, 0x15) 34 b = quicvarint.Append(b, uint64(f.StreamID)) 35 b = quicvarint.Append(b, uint64(f.MaximumStreamData)) 36 return b, nil 37 } 38 39 // Length of a written frame 40 func (f *StreamDataBlockedFrame) Length(protocol.Version) protocol.ByteCount { 41 return 1 + protocol.ByteCount(quicvarint.Len(uint64(f.StreamID))+quicvarint.Len(uint64(f.MaximumStreamData))) 42 }