### Rustdoc Settings Source: https://docs.rs/h3-quinn/0.0.10/settings This section details the configurable settings for the Rustdoc documentation generator. Users can customize themes, auto-hide behavior for documentation elements, search result handling, code example display, navigation visibility, and font preferences. ```rust Theme: light dark ayu system preference Preferred light theme: light dark ayu Preferred dark theme: light dark ayu Auto-hide item contents for large items Auto-hide item methods' documentation Auto-hide trait implementation documentation Directly go to item in search if there is only one result Show line numbers on code examples Hide persistent navigation bar Hide table of contents Hide module navigation Disable keyboard shortcuts Use sans serif fonts Word wrap source code ``` -------------------------------- ### QUIC RecvStream Trait Implementation Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib This implements the `quic::RecvStream` trait for the `RecvStream` struct. It provides methods for polling data, stopping the stream, and getting the stream ID. ```rust impl quic::RecvStream for RecvStream { type Buf = Bytes; #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_data( &mut self, cx: &mut task::Context<'_>, ) -> Poll, StreamErrorIncoming>> { if let Some(mut stream) = self.stream.take() { self.read_chunk_fut.set(async move { let chunk = stream.read_chunk(usize::MAX, true).await; (stream, chunk) }); }; let (stream, chunk) = ready!(self.read_chunk_fut.poll(cx)); self.stream = Some(stream); Poll::Ready(Ok(chunk .map_err(|e| convert_read_error_to_stream_error(e))? .map(|c| c.bytes))) } #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn stop_sending(&mut self, error_code: u64) { self.stream .as_mut() .unwrap() .stop(VarInt::from_u64(error_code).expect("invalid error_code")) .ok(); } #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn recv_id(&self) -> StreamId { let num: u64 = self.stream.as_ref().unwrap().id().into(); num.try_into().expect("invalid stream id") } } ``` -------------------------------- ### Rustdoc Help and Navigation Source: https://docs.rs/h3-quinn/0.0.10/help This section details the help dialog and keyboard shortcuts available within Rustdoc for navigating and searching documentation. It covers focusing the search field, moving through results, and expanding/collapsing sections. ```rust ## Keyboard Shortcuts `?` Show this help dialog `S` / `/` Focus the search field `↑` Move up in search results `↓` Move down in search results `←` / `→` Switch result tab (when results focused) `⏎` Go to active search result `+` Expand all sections `-` Collapse all sections ``` ```rust ## Search Tricks For a full list of all search features, take a look [here](https://doc.rust-lang.org/nightly/rustdoc/read-documentation/search.html). Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given item kind. Accepted kinds are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`. Search functions by type signature (e.g., `vec -> usize` or `-> vec` or `String, enum:Cow -> bool`) You can look for items with an exact name by putting double quotes around your request: `"string"` Look for functions that accept or return [slices](https://doc.rust-lang.org/nightly/std/primitive.slice.html) and [arrays](https://doc.rust-lang.org/nightly/std/primitive.array.html) by writing square brackets (e.g., `-> [u8]` or `[] -> Option`) Look for items inside another one by searching for a path: `vec::Vec` ``` -------------------------------- ### h3-quinn Crate Overview Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn Provides an overview of the h3-quinn crate, its purpose as a QUIC transport implementation using Quinn, and lists its dependencies and supported platforms. ```rust /// QUIC Transport implementation with Quinn /// This module implements QUIC traits with Quinn. // Dependencies: // - bytes ^1 // - futures ^0.3.28 // - h3 ^0.0.8 // - h3-datagram ^0.0.2 (optional) // - quinn ^0.11.7 // - tokio ^1 // - tokio-util ^0.7.9 // - tracing ^0.1.40 (optional) // Supported Platforms: // - i686-pc-windows-msvc // - i686-unknown-linux-gnu // - x86_64-apple-darwin // - x86_64-pc-windows-msvc // - x86_64-unknown-linux-gnu // Feature flags: (See https://docs.rs/crate/h3-quinn/0.0.10/features) ``` -------------------------------- ### Get Stream ID in h3-quinn Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Retrieves the unique identifier for the current send stream. It converts the stream's internal ID into a u64 and then attempts to convert it into a StreamId type, panicking if the conversion fails due to an invalid stream ID. ```rust #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn send_id(&self) -> StreamId { let num: u64 = self.stream.id().into(); num.try_into().expect("invalid stream id") } ``` -------------------------------- ### h3-quinn Structs Overview Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/index This section provides an overview of the key structs available in the h3-quinn library, which are fundamental for building HTTP/3 applications over QUIC. Each struct is linked to its detailed documentation and often its origin within the Quinn library. ```APIDOC Structs: AcceptBi: Future produced by [`Connection::accept_bi`](https://docs.rs/quinn/0.11.7/x86_64-unknown-linux-gnu/quinn/connection/struct.Connection.html#method.accept_bi "method quinn::connection::Connection::accept_bi") AcceptUni: Future produced by [`Connection::accept_uni`](https://docs.rs/quinn/0.11.7/x86_64-unknown-linux-gnu/quinn/connection/struct.Connection.html#method.accept_uni "method quinn::connection::Connection::accept_uni") BidiStream: Quinn-backed bidirectional stream Connection: A QUIC connection backed by Quinn Endpoint: A QUIC endpoint. OpenBi: Future produced by [`Connection::open_bi`](https://docs.rs/quinn/0.11.7/x86_64-unknown-linux-gnu/quinn/connection/struct.Connection.html#method.open_bi "method quinn::connection::Connection::open_bi") OpenStreams: Stream opener backed by a Quinn connection OpenUni: Future produced by [`Connection::open_uni`](https://docs.rs/quinn/0.11.7/x86_64-unknown-linux-gnu/quinn/connection/struct.Connection.html#method.open_uni "method quinn::connection::Connection::open_uni") RecvStream: Quinn-backed receive stream SendStream: Quinn-backed send stream VarInt: An integer less than 2^62 ``` -------------------------------- ### h3-quinn Crate Information Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Provides an overview of the h3-quinn crate, including its version, purpose, license, and links to related resources. ```rust Crate: h3-quinn Version: 0.0.10 Description: QUIC transport implementation based on Quinn. License: MIT Repository: https://github.com/hyperium/h3 Crates.io: https://crates.io/crates/h3-quinn Source Code: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib.rs.html ``` -------------------------------- ### h3-quinn Dependencies Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Lists the direct dependencies of the h3-quinn crate, including their versions and whether they are optional. ```rust Dependencies: - bytes ^1 - futures ^0.3.28 - h3 ^0.0.8 - h3-datagram ^0.0.2 (optional) - quinn ^0.11.7 - tokio ^1 - tokio-util ^0.7.9 - tracing ^0.1.40 (optional) ``` -------------------------------- ### Connection Constructor Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Constructs a new Connection instance for h3-quinn, initializing stream handlers for incoming bidirectional and unidirectional streams. ```rust pub fn new(conn: quinn::Connection) -> Self { Self { conn: conn.clone(), incoming_bi: Box::pin(stream::unfold(conn.clone(), |conn| async { Some((conn.accept_bi().await, conn)) })), opening_bi: None, incoming_uni: Box::pin(stream::unfold(conn.clone(), |conn| async { Some((conn.accept_uni().await, conn)) })), opening_uni: None, } } ``` -------------------------------- ### h3-quinn Structs Overview Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn This section provides an overview of the key structs in the h3-quinn library, detailing their purpose and relationship to Quinn's connection management. ```rust /// Represents a future for accepting bidirectional streams on a QUIC connection. /// Produced by `Connection::accept_bi`. struct AcceptBi; /// Represents a future for accepting unidirectional streams on a QUIC connection. /// Produced by `Connection::accept_uni`. struct AcceptUni; /// Represents a bidirectional stream backed by Quinn. struct BidiStream; /// Represents a QUIC connection backed by Quinn. struct Connection; /// Represents a QUIC endpoint. struct Endpoint; /// Represents a future for opening a bidirectional stream on a QUIC connection. /// Produced by `Connection::open_bi`. struct OpenBi; /// Manages opening streams on a Quinn connection. struct OpenStreams; /// Represents a future for opening a unidirectional stream on a QUIC connection. /// Produced by `Connection::open_uni`. struct OpenUni; /// Represents a receive-only stream backed by Quinn. struct RecvStream; /// Represents a send-only stream backed by Quinn. struct SendStream; /// Represents a variable-length integer, typically less than 2^62. struct VarInt; ``` -------------------------------- ### h3-quinn Platform Support Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Details the platforms for which the h3-quinn crate has been built and tested. ```rust Supported Platforms: - i686-pc-windows-msvc - i686-unknown-linux-gnu - x86_64-apple-darwin - x86_64-pc-windows-msvc - x86_64-unknown-linux-gnu ``` -------------------------------- ### h3-quinn Futures API Documentation Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct API documentation for futures-util methods as applied to h3-quinn. ```APIDOC fn try_flatten(self) -> TryFlatten Flattens the execution of this future when the successful result of this future is another future. Source: https://docs.rs/futures-util/0.3.28/x86_64-unknown-linux-gnu/futures_util/future/try_future/trait.TryFutureExt.html#method.try_flatten fn try_flatten_stream(self) -> TryFlattenStream Flattens the execution of this future when the successful result of this future is a stream. Source: https://docs.rs/futures-util/0.3.28/x86_64-unknown-linux-gnu/futures_util/future/try_future/trait.TryFutureExt.html#method.try_flatten_stream fn unwrap_or_else(self, f: F) -> UnwrapOrElse Unwraps this future’s output, producing a future with this future’s Ok type as its Output type. Source: https://docs.rs/futures-util/0.3.28/x86_64-unknown-linux-gnu/futures_util/future/try_future/trait.TryFutureExt.html#method.unwrap_or_else ``` -------------------------------- ### h3-quinn Futures API Documentation Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct This section details the futures-util methods available for use with h3-quinn, providing insights into their signatures, type constraints, and intended usage for transforming future outcomes. ```APIDOC Trait: TryFutureExt Methods: 1. map_ok(self, f: F) -> MapOk - Description: Maps this future’s success value to a different value. - Constraints: F: FnOnce(Self::Ok) -> T, Self: Sized - Returns: A new future with the success value transformed. 2. map_ok_or_else(self, e: E, f: F) -> MapOkOrElse - Description: Maps this future’s success value to a different value, and permits for error handling resulting in the same type. - Constraints: F: FnOnce(Self::Ok) -> T, E: FnOnce(Self::Error) -> T, Self: Sized - Returns: A new future with both success and error values transformed to a common type. 3. map_err(self, f: F) -> MapErr - Description: Maps this future’s error value to a different value. - Constraints: F: FnOnce(Self::Error) -> E, Self: Sized - Returns: A new future with the error value transformed. ``` -------------------------------- ### futures_util TryFutureExt Methods Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct Provides documentation for key methods from the futures_util::future::try_future::TryFutureExt trait, including err_into, ok_into, and and_then. These methods are used for transforming futures based on their success or error states. ```APIDOC fn err_into(self) -> ErrInto where Self: Sized, Self::Error: Into Maps this future’s Error to a new error type using the Into trait. [Source](https://docs.rs/futures-util/0.3.28/x86_64-unknown-linux-gnu/src/futures_util/future/try_future/mod.rs.html#351-354) ``` ```APIDOC fn ok_into(self) -> OkInto where Self: Sized, Self::Ok: Into Maps this future’s Ok to a new type using the Into trait. [Source](https://docs.rs/futures-util/0.3.28/x86_64-unknown-linux-gnu/src/futures_util/future/try_future/mod.rs.html#395-399) ``` ```APIDOC fn and_then(self, f: F) -> AndThen where F: FnOnce(Self::Ok) -> Fut, Fut: TryFuture, Self: Sized Executes another future after this one resolves successfully. The success value is passed to a closure to create this subsequent future. [Source](https://docs.rs/futures-util/0.3.28/x86_64-unknown-linux-gnu/src/futures_util/future/try_future/mod.rs.html#440-444) ``` -------------------------------- ### h3-quinn Structs Overview Source: https://docs.rs/h3-quinn/0.0.10/index This section lists and describes the primary structs available in the h3-quinn crate. It details their purpose and relationships with other components, particularly within the Quinn crate. ```rust /// Represents a future produced by `Connection::accept_bi`. struct AcceptBi; /// Represents a future produced by `Connection::accept_uni`. struct AcceptUni; /// A QUIC connection backed by Quinn. struct Connection; /// A QUIC endpoint. struct Endpoint; /// Represents a future produced by `Connection::open_bi`. struct OpenBi; /// Stream opener backed by a Quinn connection. struct OpenStreams; /// Represents a future produced by `Connection::open_uni`. struct OpenUni; /// Quinn-backed receive stream. struct RecvStream; /// Quinn-backed send stream. struct SendStream; /// An integer less than 2^62. struct VarInt; ``` -------------------------------- ### Opener Method Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Returns an `OpenStreams` struct, which is used for managing outgoing streams on the QUIC connection. ```rust fn opener(&self) -> Self::OpenStreams { OpenStreams { } } ``` -------------------------------- ### BidiStream Implementation Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib This snippet shows the implementation of the `quic::BidiStream` trait for the `BidiStream` struct in the h3-quinn crate. It includes methods for splitting the stream into send and receive components and for polling incoming data. ```rust impl quic::BidiStream for BidiStream where B: Buf, { type SendStream = SendStream; type RecvStream = RecvStream; fn split(self) -> (Self::SendStream, Self::RecvStream) { (self.send, self.recv) } } impl quic::RecvStream for BidiStream { type Buf = Bytes; fn poll_data( &mut self, cx: &mut task::Context<'_>, ) -> Poll, StreamErrorIncoming>> { self.recv.poll_data(cx) } fn stop_sending(&mut self, error_code: u64) { self.recv.stop_sending(error_code) } fn recv_id(&self) -> StreamId { self.recv.recv_id() } } ``` -------------------------------- ### Tracing WithSubscriber Methods for OpenUni Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct This section details the methods available for attaching subscribers to types implementing the `WithSubscriber` trait, as seen in the `h3-quinn` crate. These methods allow for the integration of tracing subscribers to manage and propagate telemetry data. ```APIDOC impl WithSubscriber for T vzip(self) -> V // This method is part of the VZip trait from ppv-lite86, not directly related to tracing. with_subscriber(self, subscriber: S) -> WithDispatch where S: Into // Attaches a provided Subscriber to this type. // Parameters: // subscriber: A type that can be converted into a Dispatch. // Returns: // A WithDispatch wrapper containing the original type and the attached subscriber. with_current_subscriber(self) -> WithDispatch // Attaches the current default Subscriber to this type. // Returns: // A WithDispatch wrapper containing the original type and the attached subscriber. ``` -------------------------------- ### RecvStream Implementation Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib This section details the implementation of the `RecvStream` struct, which wraps a QUIC receive stream. It includes the constructor and methods for interacting with the stream. ```rust impl RecvStream { fn new(stream: quinn::RecvStream) -> Self { Self { stream: Some(stream), // Should only allocate once the first time it's used read_chunk_fut: ReusableBoxFuture::new(async { unreachable!() }), } } } ``` -------------------------------- ### OpenStreams Clone Implementation Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib This Rust code demonstrates the `clone` implementation for the `OpenStreams` struct. It shows how to create a new `OpenStreams` instance by cloning the connection and setting the opening streams to `None`. ```rust impl Clone for OpenStreams { fn clone(&self) -> Self { Self { conn: self.conn.clone(), opening_bi: None, opening_uni: None, } } } ``` -------------------------------- ### h3-quinn Crate Structs Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/all This section lists the primary structs available in the h3-quinn crate. These structs represent core components for managing QUIC connections and streams. ```rust /// Represents an incoming bidirectional stream. pub struct AcceptBi; /// Represents an incoming unidirectional stream. pub struct AcceptUni; /// Represents a bidirectional stream. pub struct BidiStream; /// Represents a QUIC connection. pub struct Connection; /// Represents a QUIC endpoint. pub struct Endpoint; /// Represents an outgoing bidirectional stream. pub struct OpenBi; /// Represents the state of open streams. pub struct OpenStreams; /// Represents an outgoing unidirectional stream. pub struct OpenUni; /// Represents a received stream. pub struct RecvStream; /// Represents a stream that can be sent on. pub struct SendStream; /// Represents a variable-length integer. pub struct VarInt; ``` -------------------------------- ### Rust Future Extensions Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct Provides documentation for several extension methods on Rust Futures from the futures-util crate, commonly used in asynchronous programming. ```APIDOC FutureExt::inspect(self, f: F) -> Inspect - Description: Do something with the output of a future before passing it on. - Parameters: - self: The future to inspect. - f: A closure that takes a reference to the future's output. - Returns: An Inspect future. - Constraints: F must implement FnOnce(&Self::Output). FutureExt::catch_unwind(self) -> CatchUnwind - Description: Catches unwinding panics while polling the future. - Returns: A CatchUnwind future. - Constraints: Self must implement Sized and UnwindSafe. FutureExt::shared(self) -> Shared - Description: Create a cloneable handle to this future where all handles will resolve to the same result. - Returns: A Shared future. - Constraints: Self must implement Sized and Self::Output must implement Clone. FutureExt::remote_handle(self) -> (Remote, RemoteHandle) - Description: Turn this future into a future that yields `()` on completion and sends its output to another future on a separate task. - Returns: A tuple containing a Remote future and a RemoteHandle. - Constraints: Self must implement Sized. ``` -------------------------------- ### OpenUni Struct Documentation Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct Documentation for the OpenUni struct within the h3_quinn crate. This struct is central to the QUIC transport implementation. ```rust /// Represents the QUIC transport implementation. /// /// This struct is part of the h3-quinn crate and provides the core functionality /// for establishing and managing QUIC connections. pub struct OpenUni<'a> { // Internal fields related to the QUIC connection _marker: std::marker::PhantomData<&'a ()>, } // Trait Implementations for OpenUni // Future implementation impl<'a> futures::Future for OpenUni<'a> { type Output = Result<(), Box>; fn poll( self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>, ) -> std::task::Poll { // Polling logic for the QUIC connection unimplemented!("Polling logic not provided in this snippet") } } // Unpin implementation impl<'a> !Unpin for OpenUni<'a> {} // Auto Trait Implementations // !Freeze implementation impl<'a> !Freeze for OpenUni<'a> {} // !RefUnwindSafe implementation impl<'a> !RefUnwindSafe for OpenUni<'a> {} // !UnwindSafe implementation impl<'a> !UnwindSafe for OpenUni<'a> {} // Send implementation impl<'a> Send for OpenUni<'a> {} // Sync implementation impl<'a> Sync for OpenUni<'a> {} ``` -------------------------------- ### TryFutureExt: inspect_ok Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct Performs an action with the success value of a future before passing it on. This is useful for logging or side effects. ```APIDOC trait TryFutureExt { fn inspect_ok(self, f: F) -> InspectOk where F: FnOnce(&Item); } struct InspectOk where Fut: TryFuture, F: FnOnce(&Fut::Ok); impl TryFuture for InspectOk where Fut: TryFuture, F: FnOnce(&Fut::Ok>; ``` -------------------------------- ### QUIC Connection Implementation with Quinn Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib This snippet details the `Connection` struct, which serves as a QUIC connection wrapper utilizing the `quinn::Connection`. It manages incoming and outgoing bidirectional and unidirectional streams, providing an interface for QUIC transport operations. ```rust use std::{ convert::TryInto, future::Future, pin::Pin, sync::Arc, task::{self, Poll}, }; use bytes::{Buf, Bytes}; use futures::{ ready, stream::{ self}, Stream, StreamExt, }; use quinn::ReadError; pub use quinn::{self, AcceptBi, AcceptUni, Endpoint, OpenBi, OpenUni, VarInt}; use h3::( error::Code, quic::{self, ConnectionErrorIncoming, StreamErrorIncoming, StreamId, WriteBuf}, ); use tokio_util::sync::ReusableBoxFuture; #[cfg(feature = "tracing")] use tracing::instrument; #[cfg(feature = "datagram")] pub mod datagram; /// BoxStream with Sync trait type BoxStreamSync<'a, T> = Pin + Sync + Send + 'a>>; /// A QUIC connection backed by Quinn /// /// Implements a [`quic::Connection`] backed by a [`quinn::Connection`]. pub struct Connection { conn: quinn::Connection, incoming_bi: BoxStreamSync<'static, as Future>::Output>, opening_bi: Option as Future>::Output>>, incoming_uni: BoxStreamSync<'static, as Future>::Output>, opening_uni: Option as Future>::Output>>, } impl Connection { /// Create a [`Connection`] from a [`quinn::Connection`] ``` -------------------------------- ### FutureExt Methods Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct Provides methods for interacting with futures, including polling and immediate evaluation. ```rust /// Convenience for calling `Future::poll` on `Unpin` future types. fn poll_unpin(&mut self, cx: &mut Context<'_>) -> Poll where Self: Unpin, ``` ```rust /// Evaluates and consumes the future, returning the resulting output if the future is ready after the first call to `Future::poll`. fn now_or_never(self) -> Option where Self: Sized, ``` -------------------------------- ### OpenUni Blanket Implementations Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct This section details blanket implementations for the `OpenUni` struct, primarily focusing on the `Any` trait. The `Any` trait allows for runtime type identification. ```rust impl Any for T where T: 'static + ?Sized fn type_id(&self) -> TypeId ``` -------------------------------- ### Boxing Futures with `boxed` and `boxed_local` Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct These methods allow wrapping a Future in a `Box` and pinning it. `boxed` is for futures that are `Send`, while `boxed_local` is for futures that are not necessarily `Send`. This is useful for dynamic dispatch and managing futures on the heap. ```rust fn boxed<'a>(self) -> Pin + Send + 'a>> where Self: Sized + Send + 'a ``` ```rust fn boxed_local<'a>(self) -> Pin + 'a>> where Self: Sized + 'a ``` -------------------------------- ### Re-exports from Quinn Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn This section highlights that the h3-quinn crate re-exports items from the 'quinn' crate, making Quinn's functionality directly accessible. ```rust pub use quinn; ``` -------------------------------- ### h3-quinn Crate Re-exports Source: https://docs.rs/h3-quinn/0.0.10/index This section details the re-exports from the `quinn` crate within the `h3-quinn` library. It indicates that functionalities from `quinn` are made available through `h3-quinn`. ```Rust pub use quinn; ``` -------------------------------- ### QUIC SendStream Implementation Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Implements the `quic::SendStream` trait for the `SendStream` struct. This includes methods for polling stream readiness, finishing the stream, resetting the stream, and sending data. ```rust impl quic::SendStream for SendStream where B: Buf, { #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_ready(&mut self, cx: &mut task::Context<'_>) -> Poll> { if let Some(ref mut data) = self.writing { while data.has_remaining() { let stream = Pin::new(&mut self.stream); let written = ready!(stream.poll_write(cx, data.chunk())) .map_err(|err| convert_write_error_to_stream_error(err))?; data.advance(written); } } // all data is written self.writing = None; Poll::Ready(Ok(())) } #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_finish( &mut self, _cx: &mut task::Context<'_>, ) -> Poll> { Poll::Ready( self.stream .finish() .map_err(|e| StreamErrorIncoming::Unknown(Box::new(e))), ) } #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn reset(&mut self, reset_code: u64) { let _ = self .stream .reset(VarInt::from_u64(reset_code).unwrap_or(VarInt::MAX)); } #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn send_data>>(&mut self, data: D) -> Result<(), StreamErrorIncoming> { if self.writing.is_some() { // This can only happen if the traits are misused by h3 itself // If this happens log an error and close the connection with H3_INTERNAL_ERROR ``` -------------------------------- ### h3-quinn Feature Flags Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Indicates the availability of feature flags for customizing the h3-quinn crate's functionality. ```rust Feature Flags: Available feature flags for h3-quinn-0.0.10 can be browsed at https://docs.rs/crate/h3-quinn/0.0.10/features ``` -------------------------------- ### TryFuture Associated Types Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct Defines the associated types 'Ok' and 'Error' for a TryFuture, representing successful values and failures respectively. ```APIDOC type Ok = T - The type of successful values yielded by this future type Error = E - The type of failures yielded by this future ``` -------------------------------- ### Send Stream Data in h3-quinn Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Handles sending data over a QUIC send stream. It checks if the stream is ready before attempting to write data. If the stream is not ready, it returns an error. The method polls the underlying stream for write readiness and advances the buffer with the written data. ```rust impl quic::SendStreamUnframed for SendStream where B: Buf, { #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_send( &mut self, cx: &mut task::Context<'_>, buf: &mut D, ) -> Poll> { if self.writing.is_some() { // This signifies a bug in implementation panic!("poll_send called while send stream is not ready") } let s = Pin::new(&mut self.stream); let res = ready!(s.poll_write(cx, buf.chunk())); match res { Ok(written) => { buf.advance(written); Poll::Ready(Ok(written)) } Err(err) => Poll::Ready(Err(convert_write_error_to_stream_error(err))), } } } ``` -------------------------------- ### BidiStream SendStream Implementation Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Implements the `quic::SendStream` trait for `BidiStream`. This allows sending data over a QUIC bidirectional stream. ```rust impl quic::SendStream for BidiStream where B: Buf, { fn poll_ready(&mut self, cx: &mut task::Context<'_>) -> Poll> { self.send.poll_ready(cx) } fn poll_finish(&mut self, cx: &mut task::Context<'_>) -> Poll> { self.send.poll_finish(cx) } fn reset(&mut self, reset_code: u64) { self.send.reset(reset_code) } fn send_data>>(&mut self, data: D) -> Result<(), StreamErrorIncoming> { self.send.send_data(data) } fn send_id(&self) -> StreamId { self.send.send_id() } } ``` -------------------------------- ### SendStream Struct Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Represents a QUIC send stream that is backed by a Quinn send stream. It holds the Quinn send stream and a buffer for writing data. ```rust /// Quinn-backed send stream /// /// Implements a [`quic::SendStream`] backed by a [`quinn::SendStream`]. pub struct SendStream { stream: quinn::SendStream, writing: Option>, } impl where B: Buf, { fn new(stream: quinn::SendStream) -> SendStream { Self { stream: stream, writing: None, } } } ``` -------------------------------- ### Poll for Open Bidirectional Streams Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib This implementation of `quic::OpenStreams` for `Connection` polls for new bidirectional streams. It manages the opening of streams using an internal state and converts any connection errors encountered during stream opening into `StreamErrorIncoming`. ```rust impl quic::OpenStreams for Connection where B: Buf, { type SendStream = SendStream; type BidiStream = BidiStream; #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_open_bidi( &mut self, cx: &mut task::Context<'_>, ) -> Poll> { let bi = self.opening_bi.get_or_insert_with(|| { Box::pin(stream::unfold(self.conn.clone(), |conn| async { Some((conn.open_bi().await, conn)) })) }); let (send, recv) = ready!(bi.poll_next_unpin(cx)) .expect("BoxStream does not return None") .map_err(|e| StreamErrorIncoming::ConnectionErrorIncoming { connection_error: convert_connection_error(e), }); Poll::Ready(Ok(BidiStream(send, recv))) } } ``` -------------------------------- ### h3-quinn Crate Re-exports Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/index This section lists the re-exports from the 'quinn' crate within the h3-quinn library. It indicates that functionalities from the 'quinn' crate are made available through h3-quinn. ```rust pub use quinn; ``` -------------------------------- ### RecvStream Definition Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Defines the `RecvStream` struct, which represents a QUIC receive stream backed by `quinn::RecvStream`. It includes a future for reading chunks of data. ```rust /// Quinn-backed receive stream /// /// Implements a [`quic::RecvStream`] backed by a [`quinn::RecvStream`]. pub struct RecvStream { stream: Option, read_chunk_fut: ReadChunkFuture, } type ReadChunkFuture = ReusableBoxFuture< 'static, ( quinn::RecvStream, Result, quinn::ReadError>, ), >; ``` -------------------------------- ### Rust Futures Utilities: map_ok_or_else Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct The `map_ok_or_else` method allows mapping both the success and error values of a future to a common output type. It takes two closures: one for success values and one for error values. This is useful when you want to handle both success and error outcomes by converting them into a uniform result type. ```rust fn map_ok_or_else(self, e: E, f: F) -> MapOkOrElse where F: FnOnce(Self::Ok) -> T, E: FnOnce(Self::Error) -> T, Self: Sized, ``` -------------------------------- ### Convert QUIC Connection Errors to H3 Incoming Errors Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib This function converts various `quinn::ConnectionError` types into the `h3::quic::ConnectionErrorIncoming` enum. It handles specific errors like `ApplicationClosed` and `Timeout`, and groups other connection-related errors into an `Undefined` variant. ```rust fn convert_connection_error(e: quinn::ConnectionError) -> h3::quic::ConnectionErrorIncoming { match e { quinn::ConnectionError::ApplicationClosed(application_close) => { ConnectionErrorIncoming::ApplicationClose { error_code: application_close.error_code.into(), } } quinn::ConnectionError::TimedOut => ConnectionErrorIncoming::Timeout, error @ quinn::ConnectionError::VersionMismatch | error @ quinn::ConnectionError::Reset | error @ quinn::ConnectionError::LocallyClosed | error @ quinn::ConnectionError::CidsExhausted | error @ quinn::ConnectionError::TransportError(_) | error @ quinn::ConnectionError::ConnectionClosed(_) => { ConnectionErrorIncoming::Undefined(Arc::new(error)) } } } ``` -------------------------------- ### Rust Type Conversion: TryInto and TryFrom Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct Details the `TryInto` trait implementation, allowing for fallible type conversions. It defines the associated `Error` type and the `try_into` method for performing the conversion. ```rust /// The type returned in the event of a conversion error. type Error = >::Error; /// Performs the conversion. try_into(self) -> Result ``` -------------------------------- ### Open Bidirectional Stream Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Polls and opens a new bidirectional stream on the Quinn connection. It manages the underlying stream opening process and returns a `SendStream` for sending data. ```rust fn poll_open_send( &mut self, cx: &mut task::Context<'_>, ) -> Poll> { let uni = self.opening_uni.get_or_insert_with(|| { Box::pin(stream::unfold(self.conn.clone(), |conn| async { Some((conn.open_uni().await, conn)) })) }); let send = ready!(uni.poll_next_unpin(cx)) .expect("BoxStream does not return None") .map_err(|e| StreamErrorIncoming::ConnectionErrorIncoming { connection_error: convert_connection_error(e), })?; Poll::Ready(Ok(Self::SendStream::new(send))) ``` -------------------------------- ### Rust Futures Utilities: map_ok Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct The `map_ok` method transforms the success value of a future into a new value. It takes a closure that accepts the success value and returns the new success value. This is useful for applying transformations to successful results without altering the error handling. ```rust fn map_ok(self, f: F) -> MapOk where F: FnOnce(Self::Ok) -> T, Self: Sized, ``` -------------------------------- ### Into Trait Implementation Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct Provides a generic implementation for converting between types that implement `From`. ```rust /// Generic implementation for converting between types. impl Into for T where U: From, Self: Sized, ``` -------------------------------- ### Poll Accept Bidi Stream Source: https://docs.rs/h3-quinn/0.0.10/src/h3_quinn/lib Polls for and accepts an incoming bidirectional stream from the QUIC connection. This method is part of the `quic::Connection` trait implementation. ```rust fn poll_accept_bidi( &mut self, cx: &mut task::Context<'_>, ) -> Poll> { let (send, recv) = ready!(self.incoming_bi.poll_next_unpin(cx)) .expect("self.incoming_bi BoxStream never returns None") .map_err(|e| convert_connection_error(e))?; Poll::Ready(Ok(Self::BidiStream { send: Self::SendStream::new(send), recv: Self::RecvStream::new(recv), })) } ``` -------------------------------- ### TryFutureExt::flatten_sink Method Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct Flattens the execution of a TryFuture when its successful result is a Sink. This allows chaining operations where a future produces a sink. ```APIDOC fn flatten_sink(self) -> FlattenSink - Flattens the execution of this future when the successful result of this future is a Sink. - Type Parameters: - Item: The type of items the Sink accepts. - Constraints: - Self::Ok: Must implement the Sink trait for Item with the same Error type. - Self: Must be Sized. - Returns: A FlattenSink combinator. ``` -------------------------------- ### OpenUni Future Implementation Source: https://docs.rs/h3-quinn/0.0.10/h3_quinn/struct Details the implementation of the Future trait for the OpenUni struct. This indicates that OpenUni can be awaited to produce a result. The output type is a Result, which can be either a SendStream on success or a ConnectionError on failure. ```APIDOC impl Future for OpenUni<'_> type Output = Result fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll ```