Enum openid::SingleOrMultiple [−][src]
Represents a choice between a single value or multiple values. This value is serialized by serde untagged.
Examples
use biscuit::SingleOrMultiple; use serde::{Serialize, Deserialize}; #[derive(Debug, Eq, PartialEq, Serialize, Deserialize)] struct SingleOrMultipleStrings { values: SingleOrMultiple<String>, } let single = SingleOrMultipleStrings { values: SingleOrMultiple::Single("foobar".to_string()) }; let expected_json = r#"{"values":"foobar"}"#; let serialized = serde_json::to_string(&single).unwrap(); assert_eq!(expected_json, serialized); let deserialized: SingleOrMultipleStrings = serde_json::from_str(&serialized).unwrap(); assert_eq!(deserialized, single); let multiple = SingleOrMultipleStrings { values: SingleOrMultiple::Multiple(vec!["foo".to_string(), "bar".to_string(), "baz".to_string()]), }; let expected_json = r#"{"values":["foo","bar","baz"]}"#; let serialized = serde_json::to_string(&multiple).unwrap(); assert_eq!(expected_json, serialized); let deserialized: SingleOrMultipleStrings = serde_json::from_str(&serialized).unwrap(); assert_eq!(deserialized, multiple);
Variants
One single value
Multiple values
Implementations
impl<T> SingleOrMultiple<T> where
T: Clone + Debug + Eq + PartialEq<T> + Serialize + DeserializeOwned + Send + Sync,
[src]
T: Clone + Debug + Eq + PartialEq<T> + Serialize + DeserializeOwned + Send + Sync,
pub fn contains<Q>(&self, value: &Q) -> bool where
T: Borrow<Q>,
Q: PartialEq<Q> + ?Sized,
[src]
T: Borrow<Q>,
Q: PartialEq<Q> + ?Sized,
Checks whether this enum, regardless of single or multiple value contains value
.
pub fn iter(&'a self) -> Box<dyn Iterator<Item = &'a T> + 'a, Global>
[src]
Yields an iterator for the single value or the list
Trait Implementations
impl<T> Clone for SingleOrMultiple<T> where
T: Clone,
[src]
T: Clone,
pub fn clone(&self) -> SingleOrMultiple<T>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Debug for SingleOrMultiple<T> where
T: Debug,
[src]
T: Debug,
impl<'de, T> Deserialize<'de> for SingleOrMultiple<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<SingleOrMultiple<T>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]
__deserializer: __D
) -> Result<SingleOrMultiple<T>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
impl<T> Eq for SingleOrMultiple<T> where
T: Eq,
[src]
T: Eq,
impl<T> PartialEq<SingleOrMultiple<T>> for SingleOrMultiple<T> where
T: PartialEq<T>,
[src]
T: PartialEq<T>,
pub fn eq(&self, other: &SingleOrMultiple<T>) -> bool
[src]
pub fn ne(&self, other: &SingleOrMultiple<T>) -> bool
[src]
impl<T> Serialize for SingleOrMultiple<T> where
T: Serialize,
[src]
T: Serialize,
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
impl<T> StructuralEq for SingleOrMultiple<T>
[src]
impl<T> StructuralPartialEq for SingleOrMultiple<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for SingleOrMultiple<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for SingleOrMultiple<T> where
T: Send,
T: Send,
impl<T> Sync for SingleOrMultiple<T> where
T: Sync,
T: Sync,
impl<T> Unpin for SingleOrMultiple<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for SingleOrMultiple<T> where
T: UnwindSafe,
T: UnwindSafe,
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,
pub 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,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[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.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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>,