github.com/metacubex/quic-go@v0.44.1-0.20240520163451-20b689a59136/internal/wire/retire_connection_id_frame.go (about)

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