kutil_http/headers/preferences/
preference.rs1use super::{selector::*, weight::*};
2
3use std::fmt;
4
5#[derive(Clone, Debug)]
11pub struct Preference<SelectionT> {
12 pub selector: Selector<SelectionT>,
14
15 pub weight: Weight,
17}
18
19impl<SelectionT> Preference<SelectionT> {
20 pub fn new(selector: Selector<SelectionT>, weight: Weight) -> Self {
22 Self { selector, weight }
23 }
24}
25
26impl<SelectionT> fmt::Display for Preference<SelectionT>
27where
28 SelectionT: fmt::Display,
29{
30 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
31 match self.weight {
32 Weight::MAX => fmt::Display::fmt(&self.selector, formatter),
33 weight => write!(formatter, "{};{}", self.selector, weight),
34 }
35 }
36}