Skip to main content

Crate rama_http_hyperium

Crate rama_http_hyperium 

Source
Expand description

Conversions between the native rama-http-types types and the hyperium http crate equivalents, for interop with the wider http/tower/hyper ecosystem.

rama-http-types is http-free; this crate is the opt-in bridge, exposed as two sealed, fallible extension traits: TryIntoHyperiumHttp (rama → http) and TryIntoRamaHttp (http → rama). They are local traits, so they implement the foreign http types directly (no orphan rule, no conversion marker) and are callable as plain methods.

The conversions are fallible by design: an invalid method/status, an unrepresentable URI, or an invalid header name/value is surfaced as an error (the direction’s natural catch-all — http::Error one way, rama_http_types::Error the other) rather than silently coerced.

Bodies are bridged (not copied) by HyperiumBody / RamaBody, which wrap rama’s Body ↔ the external http_body::Body, converting only trailer frames.

use rama_http_hyperium::{TryIntoHyperiumHttp, TryIntoRamaHttp};

let hyper_req = http::Request::builder().uri("http://example.com/").body(()).unwrap();
let rama_req: rama_http_types::Request<()> = hyper_req.try_into_rama_http().unwrap();
assert_eq!(rama_req.uri().to_string(), "http://example.com/");

let back: http::Request<()> = rama_req.try_into_hyperium_http().unwrap();
assert_eq!(back.uri(), "http://example.com/");

Structs§

HyperiumBody
Wraps a rama Body so it implements the external http_body::Body.
RamaBody
Wraps an external http_body::Body so it implements rama’s Body.

Enums§

HyperiumBodyError
Error produced by a HyperiumBody: either the wrapped rama body failed, or its trailers couldn’t be converted to the hyperium HeaderMap.
RamaBodyError
Error produced by a RamaBody: either the wrapped external body failed, or its trailers couldn’t be converted to the rama HeaderMap.

Traits§

TryIntoHyperiumHttp
Fallibly convert a rama-http-types value into its hyperium http-crate equivalent. Sealed; the implemented set is fixed by this crate.
TryIntoRamaHttp
Fallibly convert a hyperium http-crate value into its rama-http-types equivalent. Sealed; the implemented set is fixed by this crate.