Skip to main content

oxihttp_core/
lib.rs

1//! OxiHTTP Core - foundational types for the OxiHTTP Pure-Rust HTTP stack.
2//!
3//! This crate provides the shared types used by `oxihttp-client`, `oxihttp-server`,
4//! and the `oxihttp` facade crate.
5//!
6//! # Re-exports
7//!
8//! The `http` crate types are re-exported for convenience.
9
10#![forbid(unsafe_code)]
11
12pub mod body;
13pub mod content_type;
14pub mod cookie;
15pub mod error;
16pub mod form;
17pub mod header_ext;
18pub mod header_types;
19pub mod multipart;
20pub mod request_builder;
21pub mod response_ext;
22pub mod uri_ext;
23pub mod version;
24
25// Re-export the http crate types
26pub use http::{
27    HeaderMap, HeaderName, HeaderValue, Method, Request, Response, StatusCode, Uri, Version,
28};
29
30// Re-export bytes for downstream convenience
31pub use bytes::{Bytes, BytesMut};
32
33// Re-export our types at the crate root
34pub use body::{Body, PinnedBody};
35pub use content_type::ContentType;
36pub use cookie::{Cookie, CookieJar, SameSite};
37pub use error::OxiHttpError;
38pub use form::FormBody;
39pub use header_ext::HeaderMapExt;
40pub use header_types::{
41    Authorization, CacheControl, ContentLength, ETag, Header, Host, Location, Referer,
42};
43pub use multipart::{MultipartBuilder, Part as MultipartPart};
44pub use request_builder::RequestBuilder as CoreRequestBuilder;
45pub use response_ext::ResponseExt;
46pub use uri_ext::UriExt;
47pub use version::HttpVersion;
48
49/// Type alias for `Result<T, OxiHttpError>`.
50pub type Result<T> = std::result::Result<T, OxiHttpError>;
51
52/// Type alias for an HTTP request carrying an [`Body`].
53pub type OxiRequest<B = body::Body> = http::Request<B>;
54
55/// Type alias for an HTTP response carrying an [`Body`].
56pub type OxiResponse<B = body::Body> = http::Response<B>;