github.com/danielpfeifer02/quic-go-prio-packs@v0.41.0-28/internal/wire/retire_connection_id_frame.go (about)

     1  package wire
     2  
     3  import (
     4  	"bytes"
     5  
     6  	"github.com/danielpfeifer02/quic-go-prio-packs/internal/protocol"
     7  	"github.com/danielpfeifer02/quic-go-prio-packs/quicvarint"
     8  )
     9  
    10  // A RetireConnectionIDFrame is a RETIRE_CONNECTION_ID frame
    11  type RetireConnectionIDFrame struct {
    12  	SequenceNumber uint64
    13  }
    14  
    15  func parseRetireConnectionIDFrame(r *bytes.Reader, _ protocol.Version) (*RetireConnectionIDFrame, error) {
    16  	seq, err := quicvarint.Read(r)
    17  	if err != nil {
    18  		return nil, err
    19  	}
    20  	return &RetireConnectionIDFrame{SequenceNumber: seq}, nil
    21  }
    22  
    23  func (f *RetireConnectionIDFrame) Append(b []byte, _ protocol.Version) ([]byte, error) {
    24  	b = append(b, retireConnectionIDFrameType)
    25  	b = quicvarint.Append(b, f.SequenceNumber)
    26  	return b, nil
    27  }
    28  
    29  // Length of a written frame
    30  func (f *RetireConnectionIDFrame) Length(protocol.Version) protocol.ByteCount {
    31  	return 1 + quicvarint.Len(f.SequenceNumber)
    32  }