use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub(super) enum DenyReason {
ZeroRows,
Ambiguous,
NullField(String),
MissingParam(String),
}
impl DenyReason {
pub(super) fn log_label(&self) -> String {
match self {
Self::ZeroRows => "zero-rows".to_owned(),
Self::Ambiguous => "ambiguous".to_owned(),
Self::NullField(col) => format!("null-field {col}"),
Self::MissingParam(name) => format!("missing-param {name}"),
}
}
}
#[derive(Debug, Clone)]
pub(super) struct ResolveError {
message: String,
}
impl ResolveError {
pub(super) fn new(message: impl Into<String>) -> Self {
Self {
message: message.into(),
}
}
}
impl fmt::Display for ResolveError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.message)
}
}
#[derive(Debug)]
pub(super) enum IdentityResolution {
Resolved(serde_json::Map<String, serde_json::Value>),
Denied(DenyReason),
Unavailable(ResolveError),
}