Package io.github.mahmoudimus.quic.frame
Record Class Frame.Stream
java.lang.Object
java.lang.Record
io.github.mahmoudimus.quic.frame.Frame.Stream
- Record Components:
streamId- the stream IDoffset- the offset of the data in the streamdata- the datafin- whether the data ends the stream
- All Implemented Interfaces:
Frame
- Enclosing interface:
Frame
public static record Frame.Stream(long streamId, long offset, ByteBuffer data, boolean fin)
extends Record
implements Frame
A STREAM frame (types 0x08 to 0x0f).
encode(ByteBuffer) always writes the Length
field, and the Offset field when the offset is not zero.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.mahmoudimus.quic.frame.Frame
Frame.Ack, Frame.AckFrequency, Frame.AckRange, Frame.ApplicationClose, Frame.ConnectionClose, Frame.Crypto, Frame.DataBlocked, Frame.Datagram, Frame.EcnCounts, Frame.HandshakeDone, Frame.ImmediateAck, Frame.MaxData, Frame.MaxStreamData, Frame.MaxStreams, Frame.NewConnectionId, Frame.NewToken, Frame.Padding, Frame.PathChallenge, Frame.PathResponse, Frame.Ping, Frame.ResetStream, Frame.RetireConnectionId, Frame.StopSending, Frame.Stream, Frame.StreamDataBlocked, Frame.StreamsBlocked -
Field Summary
Fields inherited from interface io.github.mahmoudimus.quic.frame.Frame
MAX_STREAM_COUNT -
Constructor Summary
ConstructorsConstructorDescriptionStream(long streamId, long offset, ByteBuffer data, boolean fin) A STREAM frame. -
Method Summary
Modifier and TypeMethodDescriptiondata()The data.voidencode(ByteBuffer out) Writes the frame at the buffer's position.static intencode(ByteBuffer out, long streamId, long offset, ByteBuffer data, boolean fin, int budget) Writes as much stream data as fits a byte budget in one STREAM frame, as quinn'swrite_stream_framesdoes.intThe encoded length.final booleanIndicates whether some other object is "equal to" this one.booleanfin()Returns the value of thefinrecord component.final inthashCode()Returns a hash code value for this object.longoffset()Returns the value of theoffsetrecord component.longstreamId()Returns the value of thestreamIdrecord component.final StringtoString()Returns a string representation of this record class.type()The frame type.longtypeCode()The exact type code this frame encodes with, flags included.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.github.mahmoudimus.quic.frame.Frame
isAckEliciting
-
Constructor Details
-
Stream
A STREAM frame.- Parameters:
streamId- the stream IDoffset- the stream offsetdata- the data between its position and limitfin- whether the data ends the stream
-
-
Method Details
-
data
The data.- Returns:
- an independent view of the data
-
encode
public static int encode(ByteBuffer out, long streamId, long offset, ByteBuffer data, boolean fin, int budget) Writes as much stream data as fits a byte budget in one STREAM frame, as quinn'swrite_stream_framesdoes. When all the data fits with a Length field the frame has one; otherwise the frame omits it, fills the whole budget and must be the last frame in the packet, so pass the packet's remaining space as the budget. FIN is set only if all the data is written.- Parameters:
out- the buffer, written at its positionstreamId- the stream IDoffset- the stream offset of the first bytedata- the data to send; its position moves past the bytes writtenfin- whether the data ends the streambudget- the most bytes the frame may take (also bounded byout.remaining())- Returns:
- the data bytes written (0 for a FIN-only or empty frame), or -1 if the frame did not fit and nothing was written
-
type
Description copied from interface:FrameThe frame type. -
typeCode
public long typeCode()Description copied from interface:FrameThe exact type code this frame encodes with, flags included. -
encodedLength
public int encodedLength()Description copied from interface:FrameThe encoded length.- Specified by:
encodedLengthin interfaceFrame- Returns:
- the bytes
Frame.encode(java.nio.ByteBuffer)writes
-
encode
Description copied from interface:FrameWrites the frame at the buffer's position. -
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. -
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. -
equals
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
streamId
public long streamId()Returns the value of thestreamIdrecord component.- Returns:
- the value of the
streamIdrecord component
-
offset
public long offset()Returns the value of theoffsetrecord component.- Returns:
- the value of the
offsetrecord component
-
fin
public boolean fin()Returns the value of thefinrecord component.- Returns:
- the value of the
finrecord component
-