github.com/quic-go/quic-go@v0.44.0/internal/wire/path_response_frame.go (about)

     1  package wire
     2  
     3  import (
     4  	"io"
     5  
     6  	"github.com/quic-go/quic-go/internal/protocol"
     7  )
     8  
     9  // A PathResponseFrame is a PATH_RESPONSE frame
    10  type PathResponseFrame struct {
    11  	Data [8]byte
    12  }
    13  
    14  func parsePathResponseFrame(b []byte, _ protocol.Version) (*PathResponseFrame, int, error) {
    15  	f := &PathResponseFrame{}
    16  	if len(b) < 8 {
    17  		return nil, 0, io.EOF
    18  	}
    19  	copy(f.Data[:], b)
    20  	return f, 8, nil
    21  }
    22  
    23  func (f *PathResponseFrame) Append(b []byte, _ protocol.Version) ([]byte, error) {
    24  	b = append(b, pathResponseFrameType)
    25  	b = append(b, f.Data[:]...)
    26  	return b, nil
    27  }
    28  
    29  // Length of a written frame
    30  func (f *PathResponseFrame) Length(_ protocol.Version) protocol.ByteCount {
    31  	return 1 + 8
    32  }