github.com/MerlinKodo/quic-go@v0.39.2/internal/wire/max_data_frame.go (about) 1 package wire 2 3 import ( 4 "bytes" 5 6 "github.com/MerlinKodo/quic-go/internal/protocol" 7 "github.com/MerlinKodo/quic-go/quicvarint" 8 ) 9 10 // A MaxDataFrame carries flow control information for the connection 11 type MaxDataFrame struct { 12 MaximumData protocol.ByteCount 13 } 14 15 // parseMaxDataFrame parses a MAX_DATA frame 16 func parseMaxDataFrame(r *bytes.Reader, _ protocol.VersionNumber) (*MaxDataFrame, error) { 17 frame := &MaxDataFrame{} 18 byteOffset, err := quicvarint.Read(r) 19 if err != nil { 20 return nil, err 21 } 22 frame.MaximumData = protocol.ByteCount(byteOffset) 23 return frame, nil 24 } 25 26 func (f *MaxDataFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) { 27 b = append(b, maxDataFrameType) 28 b = quicvarint.Append(b, uint64(f.MaximumData)) 29 return b, nil 30 } 31 32 // Length of a written frame 33 func (f *MaxDataFrame) Length(_ protocol.VersionNumber) protocol.ByteCount { 34 return 1 + quicvarint.Len(uint64(f.MaximumData)) 35 }