byte_unit/bit/adjusted/
rocket_traits.rs

1use std::str::FromStr;
2
3use rocket::{
4    form::{self, FromFormField, ValueField},
5    request::FromParam,
6};
7
8use super::AdjustedBit;
9use crate::ParseError;
10
11impl<'r> FromParam<'r> for AdjustedBit {
12    type Error = ParseError;
13
14    #[inline]
15    fn from_param(v: &'r str) -> Result<Self, Self::Error> {
16        Self::from_str(v)
17    }
18}
19
20impl<'r> FromFormField<'r> for AdjustedBit {
21    #[inline]
22    fn from_value(v: ValueField<'r>) -> form::Result<'r, Self> {
23        Ok(Self::from_str(v.value).map_err(form::Error::custom)?)
24    }
25}