use std::collections::BTreeSet;
use crate::identity::credentials::as_query::AsQuery;
#[derive(Clone, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum Prompt {
#[default]
None,
Login,
Consent,
SelectAccount,
AttemptNone,
}
impl AsRef<str> for Prompt {
fn as_ref(&self) -> &'static str {
match self {
Prompt::None => "none",
Prompt::Login => "login",
Prompt::Consent => "consent",
Prompt::SelectAccount => "select_account",
Prompt::AttemptNone => "attempt_none",
}
}
}
impl IntoIterator for Prompt {
type Item = Prompt;
type IntoIter = std::vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter {
vec![self].into_iter()
}
}
impl AsQuery for Vec<Prompt> {
fn as_query(&self) -> String {
self.iter()
.map(|s| s.as_ref())
.collect::<Vec<&str>>()
.join(" ")
}
}
impl AsQuery for BTreeSet<Prompt> {
fn as_query(&self) -> String {
self.iter()
.map(|s| s.as_ref())
.collect::<Vec<&str>>()
.join(" ")
}
}