Skip to content

Commit 10a365a

Browse files
feat: add missing features for trailer integration
1 parent 526ef1d commit 10a365a

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/headers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub use to_header_values::ToHeaderValues;
2929
pub use values::Values;
3030

3131
/// A collection of HTTP Headers.
32-
#[derive(Debug)]
32+
#[derive(Debug, PartialEq)]
3333
pub struct Headers {
3434
pub(crate) headers: HashMap<HeaderName, Vec<HeaderValue>>,
3535
}

src/headers/to_header_values.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,14 @@ impl<'a> ToHeaderValues for &'a str {
4040
Ok(Some(value).into_iter())
4141
}
4242
}
43+
44+
impl ToHeaderValues for String {
45+
type Iter = option::IntoIter<HeaderValue>;
46+
47+
fn to_header_values(&self) -> crate::Result<Self::Iter> {
48+
let value = self
49+
.parse()
50+
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
51+
Ok(Some(value).into_iter())
52+
}
53+
}

src/trailers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use std::convert::TryInto;
5555
use std::ops::{Deref, DerefMut};
5656

5757
/// A collection of trailing HTTP headers.
58-
#[derive(Debug)]
58+
#[derive(Debug, PartialEq)]
5959
pub struct Trailers {
6060
headers: Headers,
6161
}
@@ -188,7 +188,7 @@ pub struct TrailersSender {
188188

189189
impl TrailersSender {
190190
/// Create a new instance of `TrailersSender`.
191-
pub(crate) fn new(sender: Sender<crate::Result<Trailers>>) -> Self {
191+
pub fn new(sender: Sender<crate::Result<Trailers>>) -> Self {
192192
Self { sender }
193193
}
194194

0 commit comments

Comments
 (0)