pub struct QValue(/* private fields */);Expand description
A quality value: 0 to 1 in thousandths (RFC 9110 section 12.4.2). No floating point.
§Examples
use parse_net::QValue;
assert_eq!(QValue::parse(b"0.5")?.thousandths(), 500);
assert_eq!(QValue::parse(b"1.000")?, QValue::ONE);
assert!(QValue::parse(b"1.5").is_err() && QValue::parse(b".5").is_err());Implementations§
Source§impl QValue
impl QValue
Sourcepub const fn from_thousandths(t: u16) -> Option<Self>
pub const fn from_thousandths(t: u16) -> Option<Self>
The weight t thousandths, if t is at most 1000.
Sourcepub const fn thousandths(self) -> u16
pub const fn thousandths(self) -> u16
The weight in thousandths, 0 to 1000.
Sourcepub fn parse(s: &[u8]) -> Result<Self, ParseError>
pub fn parse(s: &[u8]) -> Result<Self, ParseError>
Parses ( "0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] ).
§Errors
ErrorKind::InvalidQValue for anything else (1.5, 0.1234, .5,
-1, 1.001, an empty value).
Trait Implementations§
impl Copy for QValue
impl Eq for QValue
Source§impl Ord for QValue
impl Ord for QValue
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for QValue
impl PartialOrd for QValue
impl StructuralPartialEq for QValue
Auto Trait Implementations§
impl Freeze for QValue
impl RefUnwindSafe for QValue
impl Send for QValue
impl Sync for QValue
impl Unpin for QValue
impl UnsafeUnpin for QValue
impl UnwindSafe for QValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more