Enum biscuit::StringOrUri
source · Expand description
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
extern crate biscuit;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
use std::str::FromStr;
use biscuit::{SingleOrMultiple, StringOrUri};
#[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
sourceimpl AsRef<str> for StringOrUri
impl AsRef<str> for StringOrUri
sourceimpl Clone for StringOrUri
impl Clone for StringOrUri
sourcefn clone(&self) -> StringOrUri
fn clone(&self) -> StringOrUri
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for StringOrUri
impl Debug for StringOrUri
sourceimpl<'de> Deserialize<'de> for StringOrUri
impl<'de> Deserialize<'de> for StringOrUri
sourcefn deserialize<D>(deserializer: D) -> Result<StringOrUri, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<StringOrUri, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for StringOrUri
impl Display for StringOrUri
sourceimpl FromStr for StringOrUri
impl FromStr for StringOrUri
sourceimpl Hash for StringOrUri
impl Hash for StringOrUri
sourceimpl PartialEq<StringOrUri> for StringOrUri
impl PartialEq<StringOrUri> for StringOrUri
sourcefn eq(&self, other: &StringOrUri) -> bool
fn eq(&self, other: &StringOrUri) -> bool
sourceimpl Serialize for StringOrUri
impl Serialize for StringOrUri
impl Eq for StringOrUri
impl StructuralEq for StringOrUri
impl StructuralPartialEq for StringOrUri
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.