pub struct Http2Session {
pub read_timeout: Option<Duration>,
pub write_timeout: Option<Duration>,
/* private fields */
}Fields§
§read_timeout: Option<Duration>The read timeout, which will be applied to both reading the header and the body. The timeout is reset on every read. This is not a timeout on the overall duration of the response.
write_timeout: Option<Duration>The write timeout which will be applied to writing request body. The timeout is reset on every write. This is not a timeout on the overall duration of the request.
Implementations§
Source§impl Http2Session
impl Http2Session
Sourcepub fn write_request_header(
&mut self,
req: Box<RequestHeader>,
end: bool,
) -> Result<(), Box<Error>>
pub fn write_request_header( &mut self, req: Box<RequestHeader>, end: bool, ) -> Result<(), Box<Error>>
Write the request header to the server
Sourcepub async fn write_request_body(
&mut self,
data: Bytes,
end: bool,
) -> Result<(), Box<Error>>
pub async fn write_request_body( &mut self, data: Bytes, end: bool, ) -> Result<(), Box<Error>>
Write a request body chunk
pub async fn do_write_request_body( &mut self, data: Bytes, end: bool, ) -> Result<(), Box<Error>>
Sourcepub fn finish_request_body(&mut self) -> Result<(), Box<Error>>
pub fn finish_request_body(&mut self) -> Result<(), Box<Error>>
Signal that the request body has ended
Sourcepub async fn read_response_header(&mut self) -> Result<(), Box<Error>>
pub async fn read_response_header(&mut self) -> Result<(), Box<Error>>
Read the response header
Sourcepub async fn read_response_body(&mut self) -> Result<Option<Bytes>, Box<Error>>
pub async fn read_response_body(&mut self) -> Result<Option<Bytes>, Box<Error>>
Read the response body
None means, no more body to read
Sourcepub fn response_finished(&self) -> bool
pub fn response_finished(&self) -> bool
Whether the response has ended
Sourcepub fn check_response_end_or_error(&mut self) -> Result<bool, Box<Error>>
pub fn check_response_end_or_error(&mut self) -> Result<bool, Box<Error>>
Check whether stream finished with error.
Like response_finished, but also attempts to poll the h2 stream for errors that may have
caused the stream to terminate, and returns them as H2Errors.
Sourcepub async fn read_trailers(&mut self) -> Result<Option<HeaderMap>, Box<Error>>
pub async fn read_trailers(&mut self) -> Result<Option<HeaderMap>, Box<Error>>
Read the optional trailer headers
Sourcepub fn request_header(&self) -> Option<&RequestHeader>
pub fn request_header(&self) -> Option<&RequestHeader>
The request header if it is already sent
Sourcepub fn response_header(&self) -> Option<&ResponseHeader>
pub fn response_header(&self) -> Option<&ResponseHeader>
The response header if it is already read
Sourcepub fn digest(&self) -> Option<&Digest>
pub fn digest(&self) -> Option<&Digest>
Return the Digest of the connection
For reused connection, the timing in the digest will reflect its initial handshakes The caller should check if the connection is reused to avoid misuse the timing field.
Sourcepub fn digest_mut(&mut self) -> Option<&mut Digest>
pub fn digest_mut(&mut self) -> Option<&mut Digest>
Return a mutable Digest reference for the connection
Will return None if multiple H2 streams are open.
Sourcepub fn server_addr(&self) -> Option<&SocketAddr>
pub fn server_addr(&self) -> Option<&SocketAddr>
Return the server (peer) address recorded in the connection digest.
Sourcepub fn client_addr(&self) -> Option<&SocketAddr>
pub fn client_addr(&self) -> Option<&SocketAddr>
Return the client (local) address recorded in the connection digest.
Sourcepub fn take_request_body_writer(&mut self) -> Option<SendStream<Bytes>>
pub fn take_request_body_writer(&mut self) -> Option<SendStream<Bytes>>
take the body sender to another task to perform duplex read and write
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Http2Session
impl !RefUnwindSafe for Http2Session
impl Send for Http2Session
impl Sync for Http2Session
impl Unpin for Http2Session
impl !UnwindSafe for Http2Session
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.