Struct HttpDatagramSession
pub struct HttpDatagramSession<T = Upgraded> { /* private fields */ }http and std only.Expand description
An HTTP Datagram and Capsule Protocol session on an established request.
Built from the upgraded I/O of a successful HTTP/1.x upgrade (101) or HTTP/2 and
HTTP/3 Extended CONNECT (2xx); the protocol logic above it needs no version switch.
Datagrams use a NativeDatagrams carrier when the I/O publishes one (HTTP/3 with
negotiated QUIC DATAGRAM) and DATAGRAM capsules otherwise. Control capsules always use
the reliable data stream.
§Cancellation
A send accepts its value when a poll finds no earlier accepted bytes left to write; from
then on the session owns it, and dropping the future leaves it to be written by the next
capsule send (including a datagram carried as a capsule) or close. A
native datagram send never waits for those bytes. A future dropped before that point sent
nothing. Capsule headers are never interleaved. recv is cancel safe.
Dropping a healthy sender while a capsule is partially on the wire, or receiving a
malformed data stream, aborts the carrier: through its OnMalformedMessage hook when
published, and by closing the I/O in any case, even while the other half is retained. The
peer then sees a reset where the carrier has one, and otherwise a close its decoder
reports as truncated. A sender whose writes already failed leaves the receive half alone.
Implementations§
§impl<T> HttpDatagramSession<T>where
T: AsyncRead + AsyncWrite + ExtensionsRef,
impl<T> HttpDatagramSession<T>where
T: AsyncRead + AsyncWrite + ExtensionsRef,
pub fn new(io: T) -> HttpDatagramSession<T>
pub fn new(io: T) -> HttpDatagramSession<T>
A session with the default configuration.
pub fn with_config(io: T, config: SessionConfig) -> HttpDatagramSession<T>
pub fn with_config(io: T, config: SessionConfig) -> HttpDatagramSession<T>
A session with config.
pub fn native(&self) -> Option<&NativeDatagrams>
pub fn native(&self) -> Option<&NativeDatagrams>
The negotiated native carrier, if the transport offers one.
pub async fn send_datagram(
&mut self,
payload: Bytes,
) -> Result<DatagramTransport, SessionError>
pub async fn send_datagram( &mut self, payload: Bytes, ) -> Result<DatagramTransport, SessionError>
Send an HTTP Datagram. See SessionSender::send_datagram.
pub async fn send_capsule(
&mut self,
ty: CapsuleType,
value: Bytes,
) -> Result<(), SessionError>
pub async fn send_capsule( &mut self, ty: CapsuleType, value: Bytes, ) -> Result<(), SessionError>
Send a capsule reliably. See SessionSender::send_capsule.
pub async fn start_capsule(
&mut self,
header: CapsuleHeader,
) -> Result<(), SessionError>
pub async fn start_capsule( &mut self, header: CapsuleHeader, ) -> Result<(), SessionError>
Begin a capsule whose value follows in chunks. See SessionSender::start_capsule.
pub async fn send_capsule_data(
&mut self,
chunk: Bytes,
) -> Result<(), SessionError>
pub async fn send_capsule_data( &mut self, chunk: Bytes, ) -> Result<(), SessionError>
Append value bytes to the started capsule. See SessionSender::send_capsule_data.
pub async fn recv(&mut self) -> Result<Option<SessionEvent>, SessionError>
pub async fn recv(&mut self) -> Result<Option<SessionEvent>, SessionError>
Receive the next event. See SessionReceiver::recv.
pub async fn close(&mut self) -> Result<(), SessionError>
pub async fn close(&mut self) -> Result<(), SessionError>
Finish sending. See SessionSender::close.
pub fn split(self) -> (SessionSender<T>, SessionReceiver<T>)
pub fn split(self) -> (SessionSender<T>, SessionReceiver<T>)
Split into independently usable halves, for example for a bidirectional relay.
Trait Implementations§
Auto Trait Implementations§
impl<T = Upgraded> !Freeze for HttpDatagramSession<T>
impl<T = Upgraded> !RefUnwindSafe for HttpDatagramSession<T>
impl<T = Upgraded> !UnwindSafe for HttpDatagramSession<T>
impl<T> Send for HttpDatagramSession<T>
impl<T> Sync for HttpDatagramSession<T>
impl<T> Unpin for HttpDatagramSession<T>
impl<T> UnsafeUnpin for HttpDatagramSession<T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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> ⓘ
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> ⓘ
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>
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>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more