mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-03 21:07:39 +03:00
Add ByteString to HeaderValue conversion support
This commit is contained in:
parent
2d42c4ff41
commit
b2f3bde027
3 changed files with 26 additions and 2 deletions
|
@ -1,5 +1,13 @@
|
|||
# Changes
|
||||
|
||||
## [0.1.5] - 2022-11-04
|
||||
|
||||
* Add ByteString to HeaderValue conversion support
|
||||
|
||||
## [0.1.4] - 2022-11-03
|
||||
|
||||
* Add http::Error to Error
|
||||
|
||||
## [0.1.3] - 2022-11-03
|
||||
|
||||
* Use custom `Error` and `HeaderValue` types
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "ntex-http"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
authors = ["ntex contributors <team@ntex.rs>"]
|
||||
description = "Http types for ntex framework"
|
||||
keywords = ["network", "framework", "async", "futures"]
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
)]
|
||||
use std::{cmp, convert::TryFrom, error::Error, fmt, str, str::FromStr};
|
||||
|
||||
use ntex_bytes::Bytes;
|
||||
use ntex_bytes::{ByteString, Bytes};
|
||||
|
||||
/// Represents an HTTP header field value.
|
||||
///
|
||||
|
@ -430,6 +430,14 @@ impl<'a> TryFrom<&'a String> for HeaderValue {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&'a ByteString> for HeaderValue {
|
||||
type Error = InvalidHeaderValue;
|
||||
#[inline]
|
||||
fn try_from(s: &'a ByteString) -> Result<Self, Self::Error> {
|
||||
Self::from_shared(s.as_bytes().clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&'a [u8]> for HeaderValue {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
|
@ -448,6 +456,14 @@ impl TryFrom<String> for HeaderValue {
|
|||
}
|
||||
}
|
||||
|
||||
impl TryFrom<ByteString> for HeaderValue {
|
||||
type Error = InvalidHeaderValue;
|
||||
#[inline]
|
||||
fn try_from(s: ByteString) -> Result<Self, Self::Error> {
|
||||
Self::from_shared(s.into_bytes())
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<Vec<u8>> for HeaderValue {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue