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§
- Hyperium
Body - Wraps a rama
Bodyso it implements the externalhttp_body::Body. - Rama
Body - Wraps an external
http_body::Bodyso it implements rama’sBody.
Enums§
- Hyperium
Body Error - Error produced by a
HyperiumBody: either the wrapped rama body failed, or its trailers couldn’t be converted to the hyperiumHeaderMap. - Rama
Body Error - Error produced by a
RamaBody: either the wrapped external body failed, or its trailers couldn’t be converted to the ramaHeaderMap.
Traits§
- TryInto
Hyperium Http - Fallibly convert a rama-http-types value into its hyperium
http-crate equivalent. Sealed; the implemented set is fixed by this crate. - TryInto
Rama Http - Fallibly convert a hyperium
http-crate value into its rama-http-types equivalent. Sealed; the implemented set is fixed by this crate.