pub struct Connection { /* private fields */ }Implementations§
Source§impl Connection
impl Connection
pub fn new() -> Self
Sourcepub fn start(&mut self, out: &mut [u8]) -> Result<usize, Error>
pub fn start(&mut self, out: &mut [u8]) -> Result<usize, Error>
Write the client preface, our settings, and the connection-level window update that stops a large response stalling at 65535 bytes.
Sourcepub fn request(
&mut self,
method: &str,
path: &str,
authority: &str,
scheme: &str,
extra: &[(&str, &str)],
body: &[u8],
out: &mut [u8],
) -> Result<(u32, usize), Error>
pub fn request( &mut self, method: &str, path: &str, authority: &str, scheme: &str, extra: &[(&str, &str)], body: &[u8], out: &mut [u8], ) -> Result<(u32, usize), Error>
Open a stream and send a request, headers and body together.
Returns the stream identifier and how many bytes were written.
The authority argument is authoritative; redundant host fields are
omitted. If it is empty, a single host field supplies :authority.
Sourcepub fn recv<'a>(
&mut self,
bytes: &'a [u8],
on_header: impl FnMut(&str, &str),
out: &mut [u8],
) -> Result<(Event<'a>, usize), Error>
pub fn recv<'a>( &mut self, bytes: &'a [u8], on_header: impl FnMut(&str, &str), out: &mut [u8], ) -> Result<(Event<'a>, usize), Error>
Consume one whole frame.
frame is the nine-byte header followed by exactly its payload. Replies
this connection owes — settings and ping acknowledgements, window updates
— are written to out, and the caller must send them.
Sourcepub fn finish_data(
&mut self,
header: FrameHeader,
out: &mut [u8],
) -> Result<usize, Error>
pub fn finish_data( &mut self, header: FrameHeader, out: &mut [u8], ) -> Result<usize, Error>
Complete a DATA frame whose payload was consumed incrementally by the transport adapter.
DATA does not affect HPACK state, so constrained adapters can stream a
large payload without retaining the complete frame. Flow-control credit
and stream closure still happen exactly once, after every payload byte
has been authenticated and consumed. For padded frames, use
Self::finish_data_with_length to supply the unpadded content length.
Sourcepub fn finish_data_with_length(
&mut self,
header: FrameHeader,
data_length: usize,
out: &mut [u8],
) -> Result<usize, Error>
pub fn finish_data_with_length( &mut self, header: FrameHeader, data_length: usize, out: &mut [u8], ) -> Result<usize, Error>
Complete a streamed DATA frame, supplying the unpadded content length. The adapter must validate the padding byte and consume the full payload before calling this method. Credit includes padding; Content-Length does not.