improve docs

This commit is contained in:
Rob Ede 2021-12-05 03:08:53 +00:00
parent 3e9535a052
commit 90b4f2a375
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
5 changed files with 15 additions and 12 deletions

View File

@ -38,13 +38,14 @@ pub mod map;
mod shared; mod shared;
mod utils; mod utils;
#[doc(hidden)]
pub use self::shared::*;
pub use self::as_name::AsHeaderName; pub use self::as_name::AsHeaderName;
pub use self::into_pair::IntoHeaderPair; pub use self::into_pair::IntoHeaderPair;
pub use self::into_value::IntoHeaderValue; pub use self::into_value::IntoHeaderValue;
pub use self::map::HeaderMap; pub use self::map::HeaderMap;
pub use self::shared::{
parse_extended_value, q, Charset, ContentEncoding, ExtendedValue, HttpDate,
LanguageTag, Quality, QualityItem,
};
pub use self::utils::{ pub use self::utils::{
fmt_comma_delimited, from_comma_delimited, from_one_raw_str, http_percent_encode, fmt_comma_delimited, from_comma_delimited, from_one_raw_str, http_percent_encode,
}; };

View File

@ -128,7 +128,7 @@ impl TryFrom<f32> for Quality {
} }
} }
/// Convenience function to create a [`Quality`] from a `u16` (01000) or `f32` (0.01.0). /// Convenience function to create a [`Quality`] from an `f32` (0.01.0).
/// ///
/// Not recommended for use with user input. Rely on the `TryFrom` impls where possible. /// Not recommended for use with user input. Rely on the `TryFrom` impls where possible.
/// ///

View File

@ -7,7 +7,7 @@ use super::Quality;
/// Represents an item with a quality value as defined /// Represents an item with a quality value as defined
/// in [RFC 7231 §5.3.1](https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.1). /// in [RFC 7231 §5.3.1](https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.1).
/// ///
/// # Parsing /// # Parsing and Formatting
/// This wrapper be used to parse header value items that have a q-factor annotation as well as /// This wrapper be used to parse header value items that have a q-factor annotation as well as
/// serialize items with a their q-factor. /// serialize items with a their q-factor.
/// ///

View File

@ -65,8 +65,9 @@ where
Ok(()) Ok(())
} }
/// Percent encode a sequence of bytes with a character set defined in /// Percent encode a sequence of bytes with a character set defined in [RFC 5987 §3.2].
/// <https://datatracker.ietf.org/doc/html/rfc5987#section-3.2> ///
/// [RFC 5987 §3.2]: https://datatracker.ietf.org/doc/html/rfc5987#section-3.2
#[inline] #[inline]
pub fn http_percent_encode(f: &mut fmt::Formatter<'_>, bytes: &[u8]) -> fmt::Result { pub fn http_percent_encode(f: &mut fmt::Formatter<'_>, bytes: &[u8]) -> fmt::Result {
let encoded = percent_encoding::percent_encode(bytes, HTTP_VALUE); let encoded = percent_encoding::percent_encode(bytes, HTTP_VALUE);

View File

@ -435,10 +435,10 @@ impl Field {
/// Returns the field's Content-Disposition. /// Returns the field's Content-Disposition.
/// ///
/// Per [RFC 7578 §4.2]: 'Each part MUST contain a Content-Disposition header field where the /// Per [RFC 7578 §4.2]: "Each part MUST contain a Content-Disposition header field where the
/// disposition type is "form-data". The Content-Disposition header field MUST also contain an /// disposition type is `form-data`. The Content-Disposition header field MUST also contain an
/// additional parameter of "name"; the value of the "name" parameter is the original field name /// additional parameter of `name`; the value of the `name` parameter is the original field name
/// from the form.' /// from the form."
/// ///
/// This crate validates that it exists before returning a `Field`. As such, it is safe to /// This crate validates that it exists before returning a `Field`. As such, it is safe to
/// unwrap `.content_disposition().get_name()`. The [name](Self::name) method is provided as /// unwrap `.content_disposition().get_name()`. The [name](Self::name) method is provided as
@ -451,7 +451,8 @@ impl Field {
/// Returns the field's name. /// Returns the field's name.
/// ///
/// See [content_disposition] regarding guarantees about /// See [content_disposition](Self::content_disposition) regarding guarantees about existence of
/// the name field.
pub fn name(&self) -> &str { pub fn name(&self) -> &str {
self.content_disposition() self.content_disposition()
.get_name() .get_name()