View Javadoc
1   /*
2    * Copyright 2020 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.handler.codec.quic;
17  
18  import io.netty.buffer.ByteBuf;
19  import io.netty.buffer.ByteBufHolder;
20  import io.netty.buffer.Unpooled;
21  
22  /**
23   * A QUIC STREAM_FRAME.
24   */
25  public interface QuicStreamFrame extends ByteBufHolder {
26  
27      /**
28       * An empty {@link QuicStreamFrame} that has the {@code FIN} flag set.
29       */
30      QuicStreamFrame EMPTY_FIN = new QuicStreamFrame() {
31          @Override
32          public boolean hasFin() {
33              return true;
34          }
35  
36          @Override
37          public QuicStreamFrame copy() {
38              return this;
39          }
40  
41          @Override
42          public QuicStreamFrame duplicate() {
43              return this;
44          }
45  
46          @Override
47          public QuicStreamFrame retainedDuplicate() {
48              return this;
49          }
50  
51          @Override
52          public QuicStreamFrame replace(ByteBuf content) {
53              return new DefaultQuicStreamFrame(content, hasFin());
54          }
55  
56          @Override
57          public QuicStreamFrame retain() {
58              return this;
59          }
60  
61          @Override
62          public QuicStreamFrame retain(int increment) {
63              return this;
64          }
65  
66          @Override
67          public QuicStreamFrame touch() {
68              return this;
69          }
70  
71          @Override
72          public QuicStreamFrame touch(Object hint) {
73              return this;
74          }
75  
76          @Override
77          public ByteBuf content() {
78              return Unpooled.EMPTY_BUFFER;
79          }
80  
81          @Override
82          public int refCnt() {
83              return 1;
84          }
85  
86          @Override
87          public boolean release() {
88              return false;
89          }
90  
91          @Override
92          public boolean release(int decrement) {
93              return false;
94          }
95      };
96  
97      /**
98       * Returns {@code true} if the frame has the FIN set, which means it notifies the remote peer that
99       * there will be no more writing happen. {@code false} otherwise.
100      *
101      * @return {@code true} if the FIN flag should be set, {@code false} otherwise.
102      */
103     boolean hasFin();
104 
105     @Override
106     QuicStreamFrame copy();
107 
108     @Override
109     QuicStreamFrame duplicate();
110 
111     @Override
112     QuicStreamFrame retainedDuplicate();
113 
114     @Override
115     QuicStreamFrame replace(ByteBuf content);
116 
117     @Override
118     QuicStreamFrame retain();
119 
120     @Override
121     QuicStreamFrame retain(int increment);
122 
123     @Override
124     QuicStreamFrame touch();
125 
126     @Override
127     QuicStreamFrame touch(Object hint);
128 }