Record Class HeaderLayout

java.lang.Object
java.lang.Record
io.github.mahmoudimus.quic.packet.HeaderLayout
Record Components:
start - the index of the first header byte
lengthOffset - the index of the two-byte Length field, or -1 for headers without one
packetNumberOffset - the index of the packet number, or -1 for unprotected packets
packetNumberLength - the packet number length, 1 to 4, or 0 for unprotected packets
payloadOffset - the index just past the header, where the payload starts

public record HeaderLayout(int start, int lengthOffset, int packetNumberOffset, int packetNumberLength, int payloadOffset) extends Record
Where an encoded header's fields sit in the packet buffer, so that protection can fill in the Length field and mask the packet number once the payload is written. All offsets are absolute buffer indexes.
  • Constructor Details

    • HeaderLayout

      public HeaderLayout(int start, int lengthOffset, int packetNumberOffset, int packetNumberLength, int payloadOffset)
      Creates an instance of a HeaderLayout record class.
      Parameters:
      start - the value for the start record component
      lengthOffset - the value for the lengthOffset record component
      packetNumberOffset - the value for the packetNumberOffset record component
      packetNumberLength - the value for the packetNumberLength record component
      payloadOffset - the value for the payloadOffset record component
  • Method Details

    • headerLength

      public int headerLength()
      The header length.
      Returns:
      payloadOffset - start
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • start

      public int start()
      Returns the value of the start record component.
      Returns:
      the value of the start record component
    • lengthOffset

      public int lengthOffset()
      Returns the value of the lengthOffset record component.
      Returns:
      the value of the lengthOffset record component
    • packetNumberOffset

      public int packetNumberOffset()
      Returns the value of the packetNumberOffset record component.
      Returns:
      the value of the packetNumberOffset record component
    • packetNumberLength

      public int packetNumberLength()
      Returns the value of the packetNumberLength record component.
      Returns:
      the value of the packetNumberLength record component
    • payloadOffset

      public int payloadOffset()
      Returns the value of the payloadOffset record component.
      Returns:
      the value of the payloadOffset record component