Struct Reversed
pub struct Reversed<T>(/* private fields */);Available on crate features
http-backend and http and std only.Expand description
Run HTTP/3 in the opposite role of the QUIC connection it wraps: the QUIC client serves HTTP/3 and the QUIC server sends the requests, e.g. for a device behind NAT that dials out.
The stream IDs h3 sees have their initiator flipped, also the IDs inside GOAWAY and PRIORITY_UPDATE and in h3 qlog events. So both ends must wrap their connection. draft-thomson-ptth-potato is prior art that keeps the real IDs instead, but is not implemented in Rama since this is still an early draft.
- Negotiate
Reversed::application_protocoland set it asConfig::application_protocolon both ends, so a plain h3 peer fails fast. - Requests go on streams the QUIC server opens: the QUIC client must grant it bidirectional stream credit.
- Nests with
BoxedConnectionin either order, e.g.BoxedConnection::new(Reversed::new(connection)).
Implementations§
§impl Reversed<()>
impl Reversed<()>
pub fn application_protocol() -> ApplicationProtocol
pub fn application_protocol() -> ApplicationProtocol
The ALPN of reversed HTTP/3. Not potato’s token: the stream IDs differ.
Trait Implementations§
§impl<R> BiReservation for Reversed<R>where
R: BiReservation,
impl<R> BiReservation for Reversed<R>where
R: BiReservation,
type SendStream = Reversed<<R as BiReservation>::SendStream>
type RecvStream = Reversed<<R as BiReservation>::RecvStream>
fn open( self, ) -> Result<(<Reversed<R> as BiReservation>::SendStream, <Reversed<R> as BiReservation>::RecvStream), ConnectionError>
§impl<C> Connection for Reversed<C>where
C: Connection,
impl<C> Connection for Reversed<C>where
C: Connection,
type SendStream = Reversed<<C as Connection>::SendStream>
type RecvStream = Reversed<<C as Connection>::RecvStream>
type CloseLease = <C as Connection>::CloseLease
async fn open_bi( &self, ) -> Result<(<Reversed<C> as Connection>::SendStream, <Reversed<C> as Connection>::RecvStream), ConnectionError>
async fn open_uni( &self, ) -> Result<<Reversed<C> as Connection>::SendStream, ConnectionError>
§async fn accept_bi(
&self,
) -> Result<(<Reversed<C> as Connection>::SendStream, <Reversed<C> as Connection>::RecvStream), ConnectionError>
async fn accept_bi( &self, ) -> Result<(<Reversed<C> as Connection>::SendStream, <Reversed<C> as Connection>::RecvStream), ConnectionError>
Accept the next peer-initiated bidirectional stream.
Queued incoming streams remain available after connection closure, before the terminal error.
§async fn accept_uni(
&self,
) -> Result<<Reversed<C> as Connection>::RecvStream, ConnectionError>
async fn accept_uni( &self, ) -> Result<<Reversed<C> as Connection>::RecvStream, ConnectionError>
Accept the next peer-initiated unidirectional stream.
Queued incoming streams remain available after connection closure, before the terminal error,
so HTTP/3 can drain buffered control and QPACK data.
§fn side(&self) -> Side
fn side(&self) -> Side
Which stream IDs are locally initiated. Must match the IDs the streams report.
§fn handshake_confirmed(
&self,
) -> impl Future<Output = Result<(), ConnectionError>> + Send
fn handshake_confirmed( &self, ) -> impl Future<Output = Result<(), ConnectionError>> + Send
Application data can be sent without 0-RTT replay risk.
Before resolving successfully, publish the negotiated
Config::application_protocol in
NegotiatedTlsParameters in the shared extensions.§fn is_handshake_confirmed(&self) -> bool
fn is_handshake_confirmed(&self) -> bool
Whether
Self::handshake_confirmed resolved successfully; stays true after closing.fn close(&self, error_code: VarInt, reason: &[u8])
fn closed(&self) -> impl Future<Output = ConnectionError> + Send
fn close_reason(&self) -> Option<ConnectionError>
§fn available_streams(&self, dir: Dir) -> u64
fn available_streams(&self, dir: Dir) -> u64
Locally initiated streams that can be opened now.
§fn max_concurrent_streams(&self, dir: Dir) -> u64
fn max_concurrent_streams(&self, dir: Dir) -> u64
Streams this endpoint allows the peer to have open at once.
§fn remote_stream_limit(&self, dir: Dir) -> u64
fn remote_stream_limit(&self, dir: Dir) -> u64
Cumulative count of streams this endpoint allows the peer to open.
§fn local_stream_limit(&self, dir: Dir) -> u64
fn local_stream_limit(&self, dir: Dir) -> u64
Cumulative count of streams the peer allows this endpoint to open.
§fn early_data(&self) -> EarlyData
fn early_data(&self) -> EarlyData
Where this client’s early data stands.
§fn qlog_control(&self) -> Option<ConnectionQlogControl>
fn qlog_control(&self) -> Option<ConnectionQlogControl>
The qlog sink HTTP/3 events are written to.
§fn read_datagram(
&self,
) -> impl Future<Output = Result<Bytes, ConnectionError>> + Send
fn read_datagram( &self, ) -> impl Future<Output = Result<Bytes, ConnectionError>> + Send
Receive the next QUIC DATAGRAM payload.
Dropping a pending future must not discard a datagram; HTTP/3 selects this future
alongside other connection work.
fn max_datagram_size(&self) -> Option<usize>
§fn datagram_receive_enabled(&self) -> bool
fn datagram_receive_enabled(&self) -> bool
The peer may send QUIC DATAGRAM frames to this endpoint.
§fn received_datagrams(&self) -> usize
fn received_datagrams(&self) -> usize
Datagrams received and not yet taken by
Self::read_datagram.§fn datagram_send_ready(
&self,
) -> impl Future<Output = ()> + Send + 'static + use<C>
fn datagram_send_ready( &self, ) -> impl Future<Output = ()> + Send + 'static + use<C>
Room on the datagram send queue, or the connection closed. Registered when called:
create it before a send that may be refused as blocked and await it after the refusal.
§fn close_lease(&self) -> <C as Connection>::CloseLease
fn close_lease(&self) -> <C as Connection>::CloseLease
Holds off this connection’s close at a graceful shutdown until dropped, so a tunnel
can still send what it carries.
§impl<C> ExtensionsRef for Reversed<C>where
C: ExtensionsRef,
impl<C> ExtensionsRef for Reversed<C>where
C: ExtensionsRef,
§fn extensions(&self) -> &Extensions
fn extensions(&self) -> &Extensions
Get reference to the underlying
Extensions store§impl<R> RecvStream for Reversed<R>where
R: RecvStream,
impl<R> RecvStream for Reversed<R>where
R: RecvStream,
fn id(&self) -> StreamId
§fn poll_read_chunk(
&mut self,
cx: &mut Context<'_>,
max_length: usize,
) -> Poll<Result<Option<Bytes>, ReadError>>
fn poll_read_chunk( &mut self, cx: &mut Context<'_>, max_length: usize, ) -> Poll<Result<Option<Bytes>, ReadError>>
Read the next in-order chunk of at most
max_length bytes; None at the end of the stream.
Deliver already received, contiguous bytes before reporting connection loss, including
after a clean connection close, so HTTP/3 can drain buffered control and QPACK data.
Returning Pending must not consume bytes and must arrange to wake cx when data or
a terminal result becomes available.§fn stop(&mut self, error_code: VarInt) -> Result<(), ClosedStream>
fn stop(&mut self, error_code: VarInt) -> Result<(), ClosedStream>
Stop this
RecvStream with error_code§fn boxed(self) -> Box<dyn RecvStream>where
Self: Sized,
fn boxed(self) -> Box<dyn RecvStream>where
Self: Sized,
Erase the stream’s type, without boxing an already boxed stream.
§impl<C> ReserveBiStreams for Reversed<C>where
C: ReserveBiStreams,
impl<C> ReserveBiStreams for Reversed<C>where
C: ReserveBiStreams,
type Reservation = Reversed<<C as ReserveBiStreams>::Reservation>
§fn try_reserve_bi(
&self,
) -> Result<Option<<Reversed<C> as ReserveBiStreams>::Reservation>, ConnectionError>
fn try_reserve_bi( &self, ) -> Result<Option<<Reversed<C> as ReserveBiStreams>::Reservation>, ConnectionError>
None before the handshake completes or while credit is exhausted.§fn subscribe_bi_stream_budget(&self, listener: Weak<dyn ChangeListener>)
fn subscribe_bi_stream_budget(&self, listener: Weak<dyn ChangeListener>)
Notify
listener when locally initiated bidirectional stream credit becomes available,
the handshake completes, or the connection closes, until the listener is dropped.
Acquiring or consuming a reservation need not notify listeners. Subscribe before trying
to reserve credit to avoid missing a notification.§impl<S> SendStream for Reversed<S>where
S: SendStream,
impl<S> SendStream for Reversed<S>where
S: SendStream,
type Handle = <S as SendStream>::Handle
fn id(&self) -> StreamId
§fn poll_write_chunks(
&mut self,
cx: &mut Context<'_>,
chunks: &mut [Bytes],
reserve: u64,
) -> Poll<Result<(), WriteError>>
fn poll_write_chunks( &mut self, cx: &mut Context<'_>, chunks: &mut [Bytes], reserve: u64, ) -> Poll<Result<(), WriteError>>
Write a prefix of
chunks, consuming what was written.
All accepted bytes must be removed from chunks, including partial chunks, on every
poll. When returning Pending, arrange to wake cx when writing can make progress. Read more§fn try_write_generated(
&mut self,
reserve: u64,
generate: impl FnOnce(usize) -> Bytes,
) -> Result<(), WriteError>
fn try_write_generated( &mut self, reserve: u64, generate: impl FnOnce(usize) -> Bytes, ) -> Result<(), WriteError>
Write the chunk
generate builds for the credit available now (minus reserve, 0 if
unknown), calling it exactly once and atomically: QPACK commits encoder state inside it.§fn finish(&mut self) -> Result<(), ClosedStream>
fn finish(&mut self) -> Result<(), ClosedStream>
Finish this
SendStream§fn reset(&mut self, error_code: VarInt) -> Result<(), ClosedStream>
fn reset(&mut self, error_code: VarInt) -> Result<(), ClosedStream>
Reset this
SendStream with the given error_code§fn set_priority(&self, priority: i32) -> Result<(), ClosedStream>
fn set_priority(&self, priority: i32) -> Result<(), ClosedStream>
Set priority of this stream
§fn stopped(
&self,
) -> impl Future<Output = Result<Option<VarInt>, StoppedError>> + Send + Sync + 'static + use<S>
fn stopped( &self, ) -> impl Future<Output = Result<Option<VarInt>, StoppedError>> + Send + Sync + 'static + use<S>
Resolves with the peer’s STOP_SENDING code, or
None once all data is acknowledged.fn handle(&self) -> <Reversed<S> as SendStream>::Handle
§fn boxed_handle(&self) -> Arc<dyn StreamHandle> ⓘ
fn boxed_handle(&self) -> Arc<dyn StreamHandle> ⓘ
Erase the stream handle’s type, reusing an existing shared handle when available.
Auto Trait Implementations§
impl<T> Freeze for Reversed<T>where
T: Freeze,
impl<T> RefUnwindSafe for Reversed<T>where
T: RefUnwindSafe,
impl<T> Send for Reversed<T>where
T: Send,
impl<T> Sync for Reversed<T>where
T: Sync,
impl<T> Unpin for Reversed<T>where
T: Unpin,
impl<T> UnsafeUnpin for Reversed<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Reversed<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> ForwardedClientExt for Twhere
T: ExtensionsRef + ?Sized,
impl<T> ForwardedClientExt for Twhere
T: ExtensionsRef + ?Sized,
§fn forwarded_client(&self) -> Option<&ForwardedElement>
fn forwarded_client(&self) -> Option<&ForwardedElement>
The element describing the client.
§fn forwarded_client_ip(&self) -> Option<IpAddr>
fn forwarded_client_ip(&self) -> Option<IpAddr>
The client’s IP, from its
for node.§fn forwarded_client_socket_addr(&self) -> Option<SocketAddress>
fn forwarded_client_socket_addr(&self) -> Option<SocketAddress>
The client’s IP and port, from its
for node.§fn forwarded_client_host(&self) -> Option<&ForwardedAuthority>
fn forwarded_client_host(&self) -> Option<&ForwardedAuthority>
The host the client asked for.
§fn forwarded_client_proto(&self) -> Option<ForwardedProtocol>
fn forwarded_client_proto(&self) -> Option<ForwardedProtocol>
The protocol the client used.
§fn forwarded_client_version(&self) -> Option<ForwardedVersion>
fn forwarded_client_version(&self) -> Option<ForwardedVersion>
The HTTP version the client used.
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Create a new
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more