Struct id30::Id30Parse

source ·
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 is true 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 Debug for Id30Parse

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Id30Parse

source§

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 FromStr for Id30Parse

§

type Err = ParseError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl PartialEq for Id30Parse

source§

fn eq(&self, other: &Id30Parse) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Id30Parse

source§

impl StructuralPartialEq for Id30Parse

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoSql for T

source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
source§

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
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,