Debian Codegraph @

src/params.rs

raw symbols SCIP
1 use superrust-analyzer cargo mediatype 0.23.0 crate/::{namerust-analyzer cargo mediatype 0.23.0 name/::*, parserust-analyzer cargo mediatype 0.23.0 parse/::*, valuerust-analyzer cargo mediatype 0.23.0 value/::*};
2
3 /// An iterator over the parameters.
4 #[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:)]
5 pub struct Paramsrust-analyzer cargo mediatype 0.23.0 params/Params#<'a> {
6 sourcerust-analyzer cargo mediatype 0.23.0 params/Params#source.: ParamsSourcerust-analyzer cargo mediatype 0.23.0 params/ParamsSource#<'a>,
7 indexrust-analyzer cargo mediatype 0.23.0 params/Params#index.: usize,
8 }
9
10 impl<'a> Paramsrust-analyzer cargo mediatype 0.23.0 params/Params#<'a> {
11 pub(craterust-analyzer cargo mediatype 0.23.0 crate/) const fn from_slicerust-analyzer cargo mediatype 0.23.0 params/impl#[`Params<'a>`]from_slice().(s: &'a [(Namerust-analyzer cargo mediatype 0.23.0 name/Name#<'a>, Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'a>)]) -> Selfrust-analyzer cargo mediatype 0.23.0 params/impl#[`Params<'a>`] {
12 Selfrust-analyzer cargo mediatype 0.23.0 params/impl#[`Params<'a>`] {
13 sourcerust-analyzer cargo mediatype 0.23.0 params/Params#source.: ParamsSourcerust-analyzer cargo mediatype 0.23.0 params/ParamsSource#::Slicerust-analyzer cargo mediatype 0.23.0 params/ParamsSource#Slice#(s),
14 indexrust-analyzer cargo mediatype 0.23.0 params/Params#index.: 0,
15 }
16 }
17
18 pub(craterust-analyzer cargo mediatype 0.23.0 crate/) const fn from_indicesrust-analyzer cargo mediatype 0.23.0 params/impl#[`Params<'a>`]from_indices().(s: &'a str, i: &'a Indicesrust-analyzer cargo mediatype 0.23.0 parse/Indices#) -> Selfrust-analyzer cargo mediatype 0.23.0 params/impl#[`Params<'a>`] {
19 Selfrust-analyzer cargo mediatype 0.23.0 params/impl#[`Params<'a>`] {
20 sourcerust-analyzer cargo mediatype 0.23.0 params/Params#source.: ParamsSourcerust-analyzer cargo mediatype 0.23.0 params/ParamsSource#::Indicesrust-analyzer cargo mediatype 0.23.0 params/ParamsSource#Indices#(s, i),
21 indexrust-analyzer cargo mediatype 0.23.0 params/Params#index.: 0,
22 }
23 }
24 }
25
26 #[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:)]
27 enum ParamsSourcerust-analyzer cargo mediatype 0.23.0 params/ParamsSource#<'a> {
28 Slicerust-analyzer cargo mediatype 0.23.0 params/ParamsSource#Slice#(&'a [(Namerust-analyzer cargo mediatype 0.23.0 name/Name#<'a>, Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'a>)]),
29 Indicesrust-analyzer cargo mediatype 0.23.0 params/ParamsSource#Indices#(&'a str, &'a Indicesrust-analyzer cargo mediatype 0.23.0 parse/Indices#),
30 }
31
32 impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Paramsrust-analyzer cargo mediatype 0.23.0 params/Params#<'a> {
33 type Itemrust-analyzer cargo mediatype 0.23.0 params/impl#[`Params<'a>`][Iterator]Item# = (Namerust-analyzer cargo mediatype 0.23.0 name/Name#<'a>, Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'a>);
34
35 fn nextrust-analyzer cargo mediatype 0.23.0 params/impl#[`Params<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo mediatype 0.23.0 params/impl#[`Params<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
36 let index = self.indexrust-analyzer cargo mediatype 0.23.0 params/Params#index.;
37 match self.sourcerust-analyzer cargo mediatype 0.23.0 params/Params#source. {
38 ParamsSourcerust-analyzer cargo mediatype 0.23.0 params/ParamsSource#::Slicerust-analyzer cargo mediatype 0.23.0 params/ParamsSource#Slice#(s) => {
39 if index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
40 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
41 } else {
42 self.indexrust-analyzer cargo mediatype 0.23.0 params/Params#index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
43 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..0, s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..1))
44 }
45 }
46 ParamsSourcerust-analyzer cargo mediatype 0.23.0 params/ParamsSource#::Indicesrust-analyzer cargo mediatype 0.23.0 params/ParamsSource#Indices#(s, i) => {
47 if index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().i.paramsrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]params().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
48 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
49 } else {
50 self.indexrust-analyzer cargo mediatype 0.23.0 params/Params#index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
51 let param = i.paramsrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]params().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
52 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((
53 Namerust-analyzer cargo mediatype 0.23.0 name/Name#::new_uncheckedrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]new_unchecked().(&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().param[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#param[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().),
54 Valuerust-analyzer cargo mediatype 0.23.0 value/Value#::new_uncheckedrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]new_unchecked().(&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().param[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#param[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().),
55 ))
56 }
57 }
58 }
59 }
60
61 fn size_hintrust-analyzer cargo mediatype 0.23.0 params/impl#[`Params<'a>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) {
62 let len = match self.sourcerust-analyzer cargo mediatype 0.23.0 params/Params#source. {
63 ParamsSourcerust-analyzer cargo mediatype 0.23.0 params/ParamsSource#::Slicerust-analyzer cargo mediatype 0.23.0 params/ParamsSource#Slice#(s) => s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(),
64 ParamsSourcerust-analyzer cargo mediatype 0.23.0 params/ParamsSource#::Indicesrust-analyzer cargo mediatype 0.23.0 params/ParamsSource#Indices#(_, i) => i.paramsrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]params().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(),
65 };
66 (len, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(len))
67 }
68 }
69
70 /// A trait for getting parameter values.
71 pub trait ReadParamsrust-analyzer cargo mediatype 0.23.0 params/ReadParams# {
72 /// Returns the parameters.
73 fn paramsrust-analyzer cargo mediatype 0.23.0 params/ReadParams#params().(&self) -> Paramsrust-analyzer cargo mediatype 0.23.0 params/Params#<'_>;
74
75 /// Gets the parameter value by its name.
76 ///
77 /// If the same name appears more than once, returns the last value.
78 fn get_paramrust-analyzer cargo mediatype 0.23.0 params/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#<'_>>;
79 }
80
81 /// A trait for mutating parameter values.
82 pub trait WriteParamsrust-analyzer cargo mediatype 0.23.0 params/WriteParams#<'a>: ReadParamsrust-analyzer cargo mediatype 0.23.0 params/ReadParams# {
83 /// Sets a parameter value.
84 ///
85 /// If the parameters with the name already exist, they will be removed.
86 ///
87 /// ```
88 /// # use mediatype::{names::*, values::*, MediaType, WriteParams};
89 /// let madia_type = "text/plain; charset=UTF-8; charset=US-ASCII; format=fixed";
90 ///
91 /// let mut text_plain = MediaType::parse(madia_type).unwrap();
92 /// text_plain.set_param(CHARSET, UTF_8);
93 ///
94 /// assert_eq!(
95 /// text_plain.to_string(),
96 /// "text/plain; format=fixed; charset=UTF-8"
97 /// );
98 /// ```
99 fn set_paramrust-analyzer cargo mediatype 0.23.0 params/WriteParams#set_param().<'n: 'a, 'v: 'a>(&mut self, name: Namerust-analyzer cargo mediatype 0.23.0 name/Name#<'n>, value: Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'v>);
100
101 /// Removes all parameters with the name.
102 fn remove_paramsrust-analyzer cargo mediatype 0.23.0 params/WriteParams#remove_params().(&mut self, name: Namerust-analyzer cargo mediatype 0.23.0 name/Name#);
103
104 /// Removes all parameters.
105 fn clear_paramsrust-analyzer cargo mediatype 0.23.0 params/WriteParams#clear_params().(&mut self);
106 }