| 1 | use superrust-analyzer cargo mediatype 0.23.0 crate/::{errorrust-analyzer cargo mediatype 0.23.0 error/::*, media_typerust-analyzer cargo mediatype 0.23.0 media_type/::*, namerust-analyzer cargo mediatype 0.23.0 name/::*, paramsrust-analyzer cargo mediatype 0.23.0 params/::*, parserust-analyzer cargo mediatype 0.23.0 parse/::*, valuerust-analyzer cargo mediatype 0.23.0 value/::*}; |
| 2 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::{ |
| 3 | borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#, |
| 4 | boxedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/::Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#, |
| 5 | collectionsrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/::BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#, |
| 6 | stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::{Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#}, |
| 7 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#, |
| 8 | }; |
| 9 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{ |
| 10 | fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/, |
| 11 | hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/::{Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#}, |
| 12 | strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#, |
| 13 | }; |
| 14 | |
| 15 | /// An owned and immutable media type. |
| 16 | /// |
| 17 | /// ``` |
| 18 | /// use mediatype::{names::*, values::*, MediaType, MediaTypeBuf, ReadParams}; |
| 19 | /// |
| 20 | /// let text_plain: MediaTypeBuf = "text/plain; charset=UTF-8".parse().unwrap(); |
| 21 | /// assert_eq!(text_plain.get_param(CHARSET).unwrap(), UTF_8); |
| 22 | /// |
| 23 | /// let mut text_markdown: MediaType = text_plain.to_ref(); |
| 24 | /// text_markdown.subty = MARKDOWN; |
| 25 | /// assert_eq!(text_markdown.to_string(), "text/markdown; charset=UTF-8"); |
| 26 | /// ``` |
| 27 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 28 | pub struct MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# { |
| 29 | datarust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#data.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<str>, |
| 30 | indicesrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#indices.: Indicesrust-analyzer cargo mediatype 0.23.0 parse/Indices#, |
| 31 | } |
| 32 | |
| 33 | impl MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# { |
| 34 | /// Constructs a `MediaTypeBuf` from a top-level type and a subtype. |
| 35 | #[must_use] |
| 36 | pub fn newrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]new().(ty: Namerust-analyzer cargo mediatype 0.23.0 name/Name#, subty: Namerust-analyzer cargo mediatype 0.23.0 name/Name#) -> Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf] { |
| 37 | Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]::from_stringrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]from_string().([ty.as_strrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]as_str().(), "/", subty.as_strrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]as_str().()].concatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]concat().()) |
| 38 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("`ty` and `subty` should be valid") |
| 39 | } |
| 40 | |
| 41 | /// Constructs a `MediaTypeBuf` with an optional suffix and parameters. |
| 42 | #[must_use] |
| 43 | pub fn from_partsrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]from_parts().( |
| 44 | ty: Namerust-analyzer cargo mediatype 0.23.0 name/Name#, |
| 45 | subty: Namerust-analyzer cargo mediatype 0.23.0 name/Name#, |
| 46 | suffix: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Namerust-analyzer cargo mediatype 0.23.0 name/Name#>, |
| 47 | params: &[(Namerust-analyzer cargo mediatype 0.23.0 name/Name#, Valuerust-analyzer cargo mediatype 0.23.0 value/Value#)], |
| 48 | ) -> Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf] { |
| 49 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Write#; |
| 50 | let mut s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(); |
| 51 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(s, "{}/{}", ty, subty).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("`ty` and `subty` should be valid"); |
| 52 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(suffix) = suffix { |
| 53 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(s, "+{}", suffix).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 54 | } |
| 55 | for (name, value) in params { |
| 56 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(s, "; {}={}", name, value).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 57 | } |
| 58 | Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]::from_stringrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]from_string().(s).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("all values should be valid") |
| 59 | } |
| 60 | |
| 61 | /// Constructs a `MediaTypeBuf` from [`String`]. |
| 62 | /// |
| 63 | /// Unlike [`FromStr::from_str`], this function takes the ownership of [`String`] |
| 64 | /// instead of making a new copy. |
| 65 | /// |
| 66 | /// # Errors |
| 67 | /// |
| 68 | /// Returns an error if the string fails to be parsed. |
| 69 | /// |
| 70 | /// [`String`]: https://doc.rust-lang.org/std/string/struct.String.html |
| 71 | /// [`FromStr::from_str`]: https://doc.rust-lang.org/std/str/trait.FromStr.html |
| 72 | pub fn from_stringrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]from_string().(mut s: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf], MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#> { |
| 73 | let (indices, len) = Indicesrust-analyzer cargo mediatype 0.23.0 parse/Indices#::parserust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]parse().(&s)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 74 | s.truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]truncate().(len); |
| 75 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf] { |
| 76 | datarust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#data.: s.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 77 | indicesrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#indices., |
| 78 | }) |
| 79 | } |
| 80 | |
| 81 | /// Returns the top-level type. |
| 82 | #[must_use] |
| 83 | pub fn tyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]ty().(&self) -> Namerust-analyzer cargo mediatype 0.23.0 name/Name#<'_> { |
| 84 | Namerust-analyzer cargo mediatype 0.23.0 name/Name#::new_uncheckedrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]new_unchecked().(&self.datarust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#data.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indicesrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#indices..tyrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]ty().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) |
| 85 | } |
| 86 | |
| 87 | /// Returns the subtype. |
| 88 | #[must_use] |
| 89 | pub fn subtyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]subty().(&self) -> Namerust-analyzer cargo mediatype 0.23.0 name/Name#<'_> { |
| 90 | Namerust-analyzer cargo mediatype 0.23.0 name/Name#::new_uncheckedrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]new_unchecked().(&self.datarust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#data.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indicesrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#indices..subtyrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]subty().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) |
| 91 | } |
| 92 | |
| 93 | /// Returns the suffix. |
| 94 | #[must_use] |
| 95 | pub fn suffixrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]suffix().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Namerust-analyzer cargo mediatype 0.23.0 name/Name#<'_>> { |
| 96 | self.indicesrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#indices. |
| 97 | .suffixrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]suffix().() |
| 98 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|range| Namerust-analyzer cargo mediatype 0.23.0 name/Name#::new_uncheckedrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]new_unchecked().(&self.datarust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#data.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().range]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)) |
| 99 | } |
| 100 | |
| 101 | /// Returns a [`MediaType`] without parameters. |
| 102 | /// |
| 103 | /// ``` |
| 104 | /// # use mediatype::MediaTypeBuf; |
| 105 | /// # use std::str::FromStr; |
| 106 | /// let media_type: MediaTypeBuf = "image/svg+xml; charset=UTF-8".parse().unwrap(); |
| 107 | /// assert_eq!(media_type.essence().to_string(), "image/svg+xml"); |
| 108 | /// ``` |
| 109 | /// |
| 110 | /// [`MadiaType`]: ./struct.MediaType.html |
| 111 | #[must_use] |
| 112 | pub fn essencerust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]essence().(&self) -> MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#<'_> { |
| 113 | MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#::from_partsrust-analyzer cargo mediatype 0.23.0 media_type/impl#[`MediaType<'a>`]from_parts().(self.tyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]ty().(), self.subtyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]subty().(), self.suffixrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]suffix().(), &[]) |
| 114 | } |
| 115 | |
| 116 | /// Returns the underlying string. |
| 117 | #[must_use] |
| 118 | pub const fn as_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]as_str().(&self) -> &str { |
| 119 | &self.datarust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#data. |
| 120 | } |
| 121 | |
| 122 | /// Returns the canonicalized `MediaTypeBuf`. |
| 123 | /// |
| 124 | /// All strings except parameter values will be converted to lowercase. |
| 125 | /// |
| 126 | /// ``` |
| 127 | /// # use mediatype::MediaTypeBuf; |
| 128 | /// let media_type: MediaTypeBuf = "IMAGE/SVG+XML; CHARSET=UTF-8; ".parse().unwrap(); |
| 129 | /// assert_eq!( |
| 130 | /// media_type.canonicalize().to_string(), |
| 131 | /// "image/svg+xml; charset=UTF-8" |
| 132 | /// ); |
| 133 | /// ``` |
| 134 | #[must_use] |
| 135 | pub fn canonicalizerust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]canonicalize().(&self) -> Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf] { |
| 136 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Write#; |
| 137 | let mut s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]with_capacity().(self.datarust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#data..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()); |
| 138 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 139 | s, |
| 140 | "{}/{}", |
| 141 | self.tyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]ty().().as_strrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]as_str().().to_ascii_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_ascii_lowercase().(), |
| 142 | self.subtyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]subty().().as_strrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]as_str().().to_ascii_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_ascii_lowercase().() |
| 143 | ) |
| 144 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 145 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(suffix) = self.suffixrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]suffix().() { |
| 146 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(s, "+{}", suffix.as_strrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]as_str().().to_ascii_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_ascii_lowercase().()) |
| 147 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("`write` should not fail on a `String`"); |
| 148 | } |
| 149 | for (name, value) in self.paramsrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][ReadParams]params().() { |
| 150 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(s, "; {}={}", name.as_strrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]as_str().().to_ascii_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_ascii_lowercase().(), value) |
| 151 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("`write` should not fail on a `String`"); |
| 152 | } |
| 153 | s.shrink_to_fitrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]shrink_to_fit().(); |
| 154 | Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]::from_stringrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]from_string().(s).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("all values should be valid") |
| 155 | } |
| 156 | |
| 157 | /// Constructs a `MediaType` from `self`. |
| 158 | #[must_use] |
| 159 | pub fn to_refrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]to_ref().(&self) -> MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#<'_> { |
| 160 | let params = self.paramsrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][ReadParams]params().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 161 | let params = if params.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 162 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#([].as_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`]as_slice().()) |
| 163 | } else { |
| 164 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(params) |
| 165 | }; |
| 166 | MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#::from_parts_uncheckedrust-analyzer cargo mediatype 0.23.0 media_type/impl#[`MediaType<'a>`]from_parts_unchecked().(self.tyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]ty().(), self.subtyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]subty().(), self.suffixrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]suffix().(), params) |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | impl ReadParamsrust-analyzer cargo mediatype 0.23.0 params/ReadParams# for MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# { |
| 171 | fn paramsrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][ReadParams]params().(&self) -> Paramsrust-analyzer cargo mediatype 0.23.0 params/Params#<'_> { |
| 172 | Paramsrust-analyzer cargo mediatype 0.23.0 params/Params#::from_indicesrust-analyzer cargo mediatype 0.23.0 params/impl#[`Params<'a>`]from_indices().(&self.datarust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#data., &self.indicesrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#indices.) |
| 173 | } |
| 174 | |
| 175 | fn get_paramrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][ReadParams]get_param().(&self, name: Namerust-analyzer cargo mediatype 0.23.0 name/Name#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_>> { |
| 176 | self.indicesrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#indices. |
| 177 | .paramsrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]params().() |
| 178 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 179 | .revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() |
| 180 | .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/rev/impl#[`Rev<I>`][Iterator]find().(|&&[start, end, _, _]| { |
| 181 | name rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq().==rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq(). rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq().Namerust-analyzer cargo mediatype 0.23.0 name/Name#::new_uncheckedrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]new_unchecked().(&self.datarust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#data.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) |
| 182 | }) |
| 183 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|&[_, _, start, end]| { |
| 184 | Valuerust-analyzer cargo mediatype 0.23.0 value/Value#::new_uncheckedrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]new_unchecked().(&self.datarust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#data.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) |
| 185 | }) |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# { |
| 190 | type Errrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]Err# = MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#; |
| 191 | |
| 192 | fn from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr], Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 193 | let (indices, len) = Indicesrust-analyzer cargo mediatype 0.23.0 parse/Indices#::parserust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]parse().(s)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 194 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr] { |
| 195 | datarust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#data.: s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 196 | indicesrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#indices., |
| 197 | }) |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#<'_>> for MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# { |
| 202 | fn fromrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][`From<MediaType<'_>>`]from().(t: MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#) -> Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][`From<MediaType<'_>>`] { |
| 203 | Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][`From<MediaType<'_>>`]::from_stringrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]from_string().(t.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("`t` should be valid") |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#<'_>> for MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# { |
| 208 | fn fromrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][`From<&MediaType<'_>>`]from().(t: &MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#) -> Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][`From<&MediaType<'_>>`] { |
| 209 | Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][`From<&MediaType<'_>>`]::from_stringrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]from_string().(t.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("`t` should be valid") |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str> for MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# { |
| 214 | fn as_refrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][`AsRef<str>`]as_ref().(&self) -> &str { |
| 215 | &self.datarust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#data. |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# { |
| 220 | fn eqrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][`PartialEq<Self>`]eq().(&self, other: &Selfrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][`PartialEq<Self>`]) -> bool { |
| 221 | self.tyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]ty().() rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq().==rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq(). rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq().other.tyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]ty().() |
| 222 | && self.subtyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]subty().() rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq().==rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq(). rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq().other.subtyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]subty().() |
| 223 | && self.suffixrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]suffix().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().other.suffixrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]suffix().() |
| 224 | && self.paramsrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][ReadParams]params().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<_, _>>() |
| 225 | ==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`][`PartialEq<Self>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`][`PartialEq<Self>`]eq().other.paramsrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][ReadParams]params().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<_, _>>() |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | impl Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# for MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# {} |
| 230 | |
| 231 | impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#<'_>> for MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# { |
| 232 | fn eqrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][`PartialEq<MediaType<'_>>`]eq().(&self, other: &MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#) -> bool { |
| 233 | self.tyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]ty().() rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq().==rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq(). rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq().other.tyrust-analyzer cargo mediatype 0.23.0 media_type/MediaType#ty. |
| 234 | && self.subtyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]subty().() rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq().==rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq(). rust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][`PartialEq<Self>`]eq().other.subtyrust-analyzer cargo mediatype 0.23.0 media_type/MediaType#subty. |
| 235 | && self.suffixrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]suffix().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().other.suffixrust-analyzer cargo mediatype 0.23.0 media_type/MediaType#suffix. |
| 236 | && self.paramsrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][ReadParams]params().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<_, _>>() |
| 237 | ==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`][`PartialEq<Self>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`][`PartialEq<Self>`]eq().other.paramsrust-analyzer cargo mediatype 0.23.0 media_type/impl#[`MediaType<'_>`][ReadParams]params().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<_, _>>() |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<&MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#<'_>> for MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# { |
| 242 | fn eqrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][`PartialEq<&MediaType<'_>>`]eq().(&self, other: &&MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#) -> bool { |
| 243 | self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().other |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#<'_>> for &MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# { |
| 248 | fn eqrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[`&MediaTypeBuf`][`PartialEq<MediaType<'_>>`]eq().(&self, other: &MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#) -> bool { |
| 249 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().other |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# { |
| 254 | fn fmtrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 255 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}/{}", self.tyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]ty().(), self.subtyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]subty().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 256 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(suffix) = self.suffixrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]suffix().() { |
| 257 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "+{}", suffix)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 258 | } |
| 259 | for (name, value) in self.paramsrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][ReadParams]params().() { |
| 260 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "; {}={}", name, value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 261 | } |
| 262 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | impl Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# for MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf# { |
| 267 | fn hashrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][Hash]hash().<H: Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#>(&self, state: &mut H) { |
| 268 | self.tyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]ty().().hashrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][Hash]hash().(state); |
| 269 | self.subtyrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]subty().().hashrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'_>`][Hash]hash().(state); |
| 270 | self.suffixrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]suffix().().hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Hash]hash().(state); |
| 271 | self.paramsrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][ReadParams]params().() |
| 272 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<_, _>>() |
| 273 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`][IntoIterator]into_iter().() |
| 274 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>() |
| 275 | .hashrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Hash]hash().(state); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | #[cfg(test)] |
| 280 | mod testsrust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/ { |
| 281 | use superrust-analyzer cargo mediatype 0.23.0 media_type_buf/::*; |
| 282 | use craterust-analyzer cargo mediatype 0.23.0 crate/::{media_typerust-analyzer cargo mediatype 0.23.0 media_type/, namesrust-analyzer cargo mediatype 0.23.0 consts/names/::*, valuesrust-analyzer cargo mediatype 0.23.0 consts/values/::*}; |
| 283 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#; |
| 284 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::DefaultHasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/DefaultHasher#; |
| 285 | |
| 286 | fn calculate_hashrust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/calculate_hash().<T: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#>(t: &T) -> u64 { |
| 287 | let mut s = DefaultHasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/DefaultHasher#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/impl#[DefaultHasher]new().(); |
| 288 | t.hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#hash().(&mut s); |
| 289 | s.finishrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/impl#[DefaultHasher][Hasher]finish().() |
| 290 | } |
| 291 | |
| 292 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 293 | fn from_partsrust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/from_parts().() { |
| 294 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 295 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_partsrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]from_parts().(IMAGErust-analyzer cargo mediatype 0.23.0 consts/names/IMAGE., SVGrust-analyzer cargo mediatype 0.23.0 consts/names/SVG., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(XMLrust-analyzer cargo mediatype 0.23.0 consts/names/XML.), &[(CHARSETrust-analyzer cargo mediatype 0.23.0 consts/names/CHARSET., UTF_8rust-analyzer cargo mediatype 0.23.0 consts/values/UTF_8.)]).to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 296 | "image/svg+xml; charset=UTF-8" |
| 297 | ); |
| 298 | } |
| 299 | |
| 300 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 301 | fn get_paramrust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/get_param().() { |
| 302 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 303 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml") |
| 304 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 305 | .get_paramrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][ReadParams]get_param().(CHARSETrust-analyzer cargo mediatype 0.23.0 consts/names/CHARSET.), |
| 306 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 307 | ); |
| 308 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 309 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml; charset=UTF-8") |
| 310 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 311 | .get_paramrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][ReadParams]get_param().(CHARSETrust-analyzer cargo mediatype 0.23.0 consts/names/CHARSET.), |
| 312 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UTF_8rust-analyzer cargo mediatype 0.23.0 consts/values/UTF_8.) |
| 313 | ); |
| 314 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 315 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml; charset=UTF-8; HELLO=WORLD; HELLO=world") |
| 316 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 317 | .get_paramrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][ReadParams]get_param().(Namerust-analyzer cargo mediatype 0.23.0 name/Name#::newrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]new().("hello").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()), |
| 318 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Valuerust-analyzer cargo mediatype 0.23.0 value/Value#::newrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]new().("world").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()) |
| 319 | ); |
| 320 | } |
| 321 | |
| 322 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 323 | fn essencerust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/essence().() { |
| 324 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 325 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml") |
| 326 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 327 | .essencerust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]essence().() |
| 328 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 329 | "image/svg+xml" |
| 330 | ); |
| 331 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 332 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml; ") |
| 333 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 334 | .essencerust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]essence().() |
| 335 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 336 | "image/svg+xml" |
| 337 | ); |
| 338 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 339 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml; charset=UTF-8") |
| 340 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 341 | .essencerust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]essence().() |
| 342 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 343 | "image/svg+xml" |
| 344 | ); |
| 345 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 346 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml ; charset=UTF-8") |
| 347 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 348 | .essencerust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]essence().() |
| 349 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 350 | "image/svg+xml" |
| 351 | ); |
| 352 | } |
| 353 | |
| 354 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 355 | fn canonicalizerust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/canonicalize().() { |
| 356 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 357 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("IMAGE/SVG+XML; CHARSET=UTF-8; ") |
| 358 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 359 | .canonicalizerust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf]canonicalize().() |
| 360 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 361 | "image/svg+xml; charset=UTF-8" |
| 362 | ); |
| 363 | } |
| 364 | |
| 365 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 366 | fn cmprust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/cmp().() { |
| 367 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 368 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("text/plain").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 369 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("TEXT/PLAIN").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 370 | ); |
| 371 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 372 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml; charset=UTF-8").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 373 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("IMAGE/SVG+XML; CHARSET=UTF-8").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 374 | ); |
| 375 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 376 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml; hello=WORLD; charset=UTF-8").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 377 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("IMAGE/SVG+XML; HELLO=WORLD; CHARSET=UTF-8").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 378 | ); |
| 379 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 380 | MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml; charset=UTF-8").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 381 | MediaTyperust-analyzer cargo mediatype 0.23.0 media_type/MediaType#::from_partsrust-analyzer cargo mediatype 0.23.0 media_type/impl#[`MediaType<'a>`]from_parts().( |
| 382 | IMAGErust-analyzer cargo mediatype 0.23.0 consts/names/IMAGE., |
| 383 | SVGrust-analyzer cargo mediatype 0.23.0 consts/names/SVG., |
| 384 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(XMLrust-analyzer cargo mediatype 0.23.0 consts/names/XML.), |
| 385 | &[(CHARSETrust-analyzer cargo mediatype 0.23.0 consts/names/CHARSET., US_ASCIIrust-analyzer cargo mediatype 0.23.0 consts/values/US_ASCII.), (CHARSETrust-analyzer cargo mediatype 0.23.0 consts/names/CHARSET., UTF_8rust-analyzer cargo mediatype 0.23.0 consts/values/UTF_8.)] |
| 386 | ), |
| 387 | ); |
| 388 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 389 | &MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 390 | media_typerust-analyzer cargo mediatype 0.23.0 media_type!!(IMAGErust-analyzer cargo mediatype 0.23.0 consts/names/IMAGE. / SVGrust-analyzer cargo mediatype 0.23.0 consts/names/SVG. + XMLrust-analyzer cargo mediatype 0.23.0 consts/names/XML.) |
| 391 | ); |
| 392 | } |
| 393 | |
| 394 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 395 | fn hashrust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/hash().() { |
| 396 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 397 | calculate_hashrust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/calculate_hash().(&MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("text/plain").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 398 | calculate_hashrust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/calculate_hash().(&MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("TEXT/PLAIN").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()) |
| 399 | ); |
| 400 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 401 | calculate_hashrust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/calculate_hash().(&MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml; charset=UTF-8").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 402 | calculate_hashrust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/calculate_hash().(&MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("IMAGE/SVG+XML; CHARSET=UTF-8").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()) |
| 403 | ); |
| 404 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 405 | calculate_hashrust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/calculate_hash().( |
| 406 | &MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml; hello=WORLD; charset=UTF-8").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 407 | ), |
| 408 | calculate_hashrust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/calculate_hash().( |
| 409 | &MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("IMAGE/SVG+XML; HELLO=WORLD; CHARSET=UTF-8").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 410 | ) |
| 411 | ); |
| 412 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 413 | calculate_hashrust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/calculate_hash().(&MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml; charset=UTF-8").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 414 | calculate_hashrust-analyzer cargo mediatype 0.23.0 media_type_buf/tests/calculate_hash().( |
| 415 | &MediaTypeBufrust-analyzer cargo mediatype 0.23.0 media_type_buf/MediaTypeBuf#::from_strrust-analyzer cargo mediatype 0.23.0 media_type_buf/impl#[MediaTypeBuf][FromStr]from_str().("image/svg+xml; charset=US-ASCII; charset=UTF-8").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 416 | ), |
| 417 | ); |
| 418 | } |
| 419 | } |