[−][src]Enum biscuit::StringOrUri
Represents a choice between a URI or an arbitrary string. Both variants will serialize to a string. According to RFC 7519, any string containing the ":" character will be deserialized as a URL. Any invalid URLs will be treated as a deserialization failure. The URL is parsed according to the URL Standard which supersedes RFC 3986 as required in the JWT RFC.
Examples
use std::str::FromStr; use biscuit::{SingleOrMultiple, StringOrUri}; use serde::{Serialize, Deserialize}; #[derive(Debug, Eq, PartialEq, Serialize, Deserialize)] struct SingleOrMultipleStringOrUris { values: SingleOrMultiple<StringOrUri>, } let multiple = SingleOrMultipleStringOrUris { values: SingleOrMultiple::Multiple(vec![FromStr::from_str("foo").unwrap(), FromStr::from_str("https://www.bar.com/").unwrap(), FromStr::from_str("http://baz/").unwrap()]), }; let expected_json = r#"{"values":["foo","https://www.bar.com/","http://baz/"]}"#; let serialized = serde_json::to_string(&multiple).unwrap(); assert_eq!(expected_json, serialized); let deserialized: SingleOrMultipleStringOrUris = serde_json::from_str(&serialized).unwrap(); assert_eq!(deserialized, multiple);
Variants
String(String)
A generic string
Uri(Url)
A parsed URI
Trait Implementations
impl AsRef<str> for StringOrUri
[src]
impl Clone for StringOrUri
[src]
fn clone(&self) -> StringOrUri
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for StringOrUri
[src]
impl<'de> Deserialize<'de> for StringOrUri
[src]
fn deserialize<D>(deserializer: D) -> Result<StringOrUri, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Display for StringOrUri
[src]
impl Eq for StringOrUri
[src]
impl FromStr for StringOrUri
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(input: &str) -> Result<Self, Self::Err>
[src]
Parses a &str
into a StringOrUri
.
According to RFC 7519, any string containing the ":" character
will be treated as a URL. Any invalid URLs will be treated as failure.
impl Hash for StringOrUri
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<StringOrUri> for StringOrUri
[src]
fn eq(&self, other: &StringOrUri) -> bool
[src]
fn ne(&self, other: &StringOrUri) -> bool
[src]
impl Serialize for StringOrUri
[src]
impl StructuralEq for StringOrUri
[src]
impl StructuralPartialEq for StringOrUri
[src]
Auto Trait Implementations
impl RefUnwindSafe for StringOrUri
impl Send for StringOrUri
impl Sync for StringOrUri
impl Unpin for StringOrUri
impl UnwindSafe for StringOrUri
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,