Debian Codegraph @

third_party/rust/neqo-http3/src/qpack_decoder_receiver.rs

raw
1 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
2 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
4 // option. This file may not be copied, modified, or distributed
5 // except according to those terms.
6
7 use std::{cell::RefCell, rc::Rc};
8
9 use neqo_qpack::QPackDecoder;
10 use neqo_transport::{Connection, StreamId};
11
12 use crate::{CloseType, Error, Http3StreamType, ReceiveOutput, RecvStream, Res, Stream};
13
14 #[derive(Debug)]
15 pub struct DecoderRecvStream {
16 stream_id: StreamId,
17 decoder: Rc<RefCell<QPackDecoder>>,
18 }
19
20 impl DecoderRecvStream {
21 pub const fn new(stream_id: StreamId, decoder: Rc<RefCell<QPackDecoder>>) -> Self {
22 Self { stream_id, decoder }
23 }
24 }
25
26 impl Stream for DecoderRecvStream {
27 fn stream_type(&self) -> Http3StreamType {
28 Http3StreamType::Decoder
29 }
30 }
31
32 impl RecvStream for DecoderRecvStream {
33 fn reset(&mut self, _close_type: CloseType) -> Res<()> {
34 Err(Error::HttpClosedCriticalStream)
35 }
36
37 fn receive(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)> {
38 Ok((
39 ReceiveOutput::UnblockedStreams(
40 self.decoder.borrow_mut().receive(conn, self.stream_id)?,
41 ),
42 false,
43 ))
44 }
45 }