Skip to main content

turnloop_http/
lib.rs

1//! Sans-I/O HTTP codecs and host-driven client policy. No socket, executor or clock reads.
2//!
3//! # Getting started on turnloop
4//! Enable the `turnloop` feature for the `asynchronous` module. The embedding
5//! host owns `LocalExecutor` and calls `turn`; adapters await its streams and
6//! deadline futures. See the crate README and turnloop-io for ownership, streaming
7//! and cancellation examples. Default features retain the sans-I/O API.
8#![deny(unsafe_op_in_unsafe_fn)]
9pub mod client;
10pub mod compression;
11pub mod hpack;
12pub mod http1;
13pub mod http2;
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq)]
16pub struct Error {
17    pub code: &'static str,
18    pub message: &'static str,
19}
20impl Error {
21    pub const fn new(code: &'static str, message: &'static str) -> Self {
22        Self { code, message }
23    }
24}
25impl std::fmt::Display for Error {
26    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27        write!(f, "{}: {}", self.code, self.message)
28    }
29}
30impl std::error::Error for Error {}
31pub type Result<T> = std::result::Result<T, Error>;
32
33mod recycling;
34
35#[cfg(feature = "turnloop")]
36pub mod asynchronous;