pub struct Id30Parse {
pub id30: Id30,
pub is_canonical: bool,
}
Expand description
Id30Parse
represents the successful result of parsing an id30 string:
- an
Id30
value,id30
- a boolean,
is_canonical
, which istrue
iff the parsed string was in canonical encoding
When accepting id30 as input, non-canonical encodings should preferably
redirect the user to a canonical encoding of the input. For example, when
id30 is used in URLs, the server should respond with a redirect when the
id30 is not canonical. Parsing the given input as Id30Parse
yields the
information necessary to implement this.
let parse: id30::Id30Parse = "78ddpa".parse()?;
assert_eq!(u32::from(parse.id30), 243709642);
assert!(parse.is_canonical);
assert_eq!(&parse.id30.to_string(), "78ddpa");
let parse: id30::Id30Parse = "78DDPA".parse()?;
assert_eq!(u32::from(parse.id30), 243709642);
assert!(!parse.is_canonical);
assert_eq!(&parse.id30.to_string(), "78ddpa");
Fields§
§id30: Id30
§is_canonical: bool
Trait Implementations§
source§impl<'de> Deserialize<'de> for Id30Parse
impl<'de> Deserialize<'de> for Id30Parse
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq for Id30Parse
impl PartialEq for Id30Parse
impl Eq for Id30Parse
impl StructuralPartialEq for Id30Parse
Auto Trait Implementations§
impl Freeze for Id30Parse
impl RefUnwindSafe for Id30Parse
impl Send for Id30Parse
impl Sync for Id30Parse
impl Unpin for Id30Parse
impl UnwindSafe for Id30Parse
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
source§impl<T> IntoSql for T
impl<T> IntoSql for T
source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
Convert
self
to an expression for Diesel’s query builder. Read moresource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
Convert
&self
to an expression for Diesel’s query builder. Read more