Exposed the 'from_one_raw_str' function for use in defining new header structs.

This commit is contained in:
Gilman Tolle
2014-10-15 23:40:40 -07:00
parent 2ea75c967d
commit 5615ab276e
10 changed files with 26 additions and 21 deletions

View File

@@ -17,9 +17,6 @@ pub use self::server::Server;
pub use self::date::Date;
pub use self::location::Location;
use std::from_str::FromStr;
use std::str::from_utf8;
/// Exposes the Host header.
pub mod host;
@@ -50,14 +47,6 @@ pub mod date;
/// Exposes the Location header.
pub mod location;
fn from_one_raw_str<T: FromStr>(raw: &[Vec<u8>]) -> Option<T> {
if raw.len() != 1 {
return None;
}
// we JUST checked that raw.len() == 1, so raw[0] WILL exist.
match from_utf8(unsafe { raw.as_slice().unsafe_get(0).as_slice() }) {
Some(s) => FromStr::from_str(s),
None => None
}
}
pub mod util;