@@ -2,11 +2,11 @@ use HeaderValue;
2
2
3
3
// Derives an enum to represent content codings and some helpful impls
4
4
macro_rules! define_content_coding {
5
- ( $( $coding: ident; $str: expr, ) +) => {
5
+ ( $( $coding: ident; $str: expr, ) +) => {
6
6
#[ derive( Copy , Clone , Debug , Eq , PartialEq ) ]
7
- /// Values that are used with headers like [`Content-Encoding`](self::ContentEncoding) or
7
+ /// Values that are used with headers like [`Content-Encoding`](self::ContentEncoding) or
8
8
/// [`Accept-Encoding`](self::AcceptEncoding)
9
- ///
9
+ ///
10
10
/// [RFC7231](https://www.iana.org/assignments/http-parameters/http-parameters.xhtml)
11
11
pub enum ContentCoding {
12
12
$(
@@ -17,12 +17,12 @@ macro_rules! define_content_coding {
17
17
18
18
impl ContentCoding {
19
19
/// Returns a `&'static str` for a `ContentCoding`
20
- ///
20
+ ///
21
21
/// # Example
22
- ///
22
+ ///
23
23
/// ```
24
24
/// use headers::ContentCoding;
25
- ///
25
+ ///
26
26
/// let coding = ContentCoding::BROTLI;
27
27
/// assert_eq!(coding.to_static(), "br");
28
28
/// ```
@@ -33,20 +33,20 @@ macro_rules! define_content_coding {
33
33
}
34
34
}
35
35
36
- /// Given a `&str` returns a `ContentCoding`
37
- ///
38
- /// Note this will never fail, in the case of `&str` being an invalid content coding,
39
- /// will return `ContentCoding::IDENTITY` because `'identity'` is generally always an
36
+ /// Given a `&str` returns a `ContentCoding`
37
+ ///
38
+ /// Note this will never fail, in the case of `&str` being an invalid content coding,
39
+ /// will return `ContentCoding::IDENTITY` because `'identity'` is generally always an
40
40
/// accepted coding.
41
- ///
41
+ ///
42
42
/// # Example
43
- ///
43
+ ///
44
44
/// ```
45
45
/// use headers::ContentCoding;
46
- ///
46
+ ///
47
47
/// let invalid = ContentCoding::from_str("not a valid coding");
48
48
/// assert_eq!(invalid, ContentCoding::IDENTITY);
49
- ///
49
+ ///
50
50
/// let valid = ContentCoding::from_str("gzip");
51
51
/// assert_eq!(valid, ContentCoding::GZIP);
52
52
/// ```
@@ -56,18 +56,18 @@ macro_rules! define_content_coding {
56
56
}
57
57
58
58
/// Given a `&str` will try to return a `ContentCoding`
59
- ///
59
+ ///
60
60
/// Different from `ContentCoding::from_str(&str)`, if `&str` is an invalid content
61
61
/// coding, it will return `Err(())`
62
- ///
62
+ ///
63
63
/// # Example
64
- ///
64
+ ///
65
65
/// ```
66
66
/// use headers::ContentCoding;
67
- ///
67
+ ///
68
68
/// let invalid = ContentCoding::try_from_str("not a valid coding");
69
69
/// assert!(invalid.is_err());
70
- ///
70
+ ///
71
71
/// let valid = ContentCoding::try_from_str("gzip");
72
72
/// assert_eq!(valid.unwrap(), ContentCoding::GZIP);
73
73
/// ```
@@ -128,12 +128,15 @@ mod tests {
128
128
fn from_str ( ) {
129
129
assert_eq ! ( ContentCoding :: from_str( "br" ) , ContentCoding :: BROTLI ) ;
130
130
assert_eq ! ( ContentCoding :: from_str( "GZIP" ) , ContentCoding :: GZIP ) ;
131
- assert_eq ! ( ContentCoding :: from_str( "blah blah" ) , ContentCoding :: IDENTITY ) ;
131
+ assert_eq ! (
132
+ ContentCoding :: from_str( "blah blah" ) ,
133
+ ContentCoding :: IDENTITY
134
+ ) ;
132
135
}
133
136
134
137
#[ test]
135
138
fn try_from_str ( ) {
136
139
assert_eq ! ( ContentCoding :: try_from_str( "br" ) , Ok ( ContentCoding :: BROTLI ) ) ;
137
140
assert_eq ! ( ContentCoding :: try_from_str( "blah blah" ) , Err ( ( ) ) ) ;
138
141
}
139
- }
142
+ }
0 commit comments