github.com/tumi8/quic-go@v0.37.4-tum/noninternal/wire/data_blocked_frame.go (about) 1 package wire 2 3 import ( 4 "bytes" 5 6 "github.com/tumi8/quic-go/noninternal/protocol" 7 "github.com/tumi8/quic-go/quicvarint" 8 ) 9 10 // A DataBlockedFrame is a DATA_BLOCKED frame 11 type DataBlockedFrame struct { 12 MaximumData protocol.ByteCount 13 } 14 15 func parseDataBlockedFrame(r *bytes.Reader, _ protocol.VersionNumber) (*DataBlockedFrame, error) { 16 offset, err := quicvarint.Read(r) 17 if err != nil { 18 return nil, err 19 } 20 return &DataBlockedFrame{MaximumData: protocol.ByteCount(offset)}, nil 21 } 22 23 func (f *DataBlockedFrame) Append(b []byte, version protocol.VersionNumber) ([]byte, error) { 24 b = append(b, dataBlockedFrameType) 25 return quicvarint.Append(b, uint64(f.MaximumData)), nil 26 } 27 28 // Length of a written frame 29 func (f *DataBlockedFrame) Length(version protocol.VersionNumber) protocol.ByteCount { 30 return 1 + quicvarint.Len(uint64(f.MaximumData)) 31 }