From 7a7ff2d2d7fc3b5d346b368fc5d6737dee02df85 Mon Sep 17 00:00:00 2001 From: Jacob Rothstein Date: Fri, 13 Oct 2023 12:35:13 -0700 Subject: [PATCH] add `From>` and `From>` for Body --- http/src/body.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/http/src/body.rs b/http/src/body.rs index 40892217da..acb83823d8 100644 --- a/http/src/body.rs +++ b/http/src/body.rs @@ -342,6 +342,21 @@ impl From> for Body { } } +impl From> for Body { + fn from(value: Cow<'static, [u8]>) -> Self { + Self::new_static(value) + } +} + +impl From> for Body { + fn from(value: Cow<'static, str>) -> Self { + match value { + Cow::Borrowed(b) => b.into(), + Cow::Owned(o) => o.into(), + } + } +} + #[cfg(test)] mod test_bytes_to_read { #[test]