use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct VaultId(pub String);
impl VaultId {
pub fn new(s: impl Into<String>) -> Self {
Self(s.into())
}
pub fn as_str(&self) -> &str {
&self.0
}
}
impl std::fmt::Display for VaultId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
}
}
impl From<String> for VaultId {
fn from(s: String) -> Self {
Self(s)
}
}
impl From<&str> for VaultId {
fn from(s: &str) -> Self {
Self(s.to_string())
}
}
impl AsRef<str> for VaultId {
fn as_ref(&self) -> &str {
&self.0
}
}
impl PartialEq<&str> for VaultId {
fn eq(&self, other: &&str) -> bool {
self.0.as_str() == *other
}
}
impl PartialEq<str> for VaultId {
fn eq(&self, other: &str) -> bool {
self.0.as_str() == other
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct LocusId(pub String);
impl LocusId {
pub fn new(s: impl Into<String>) -> Self {
Self(s.into())
}
pub fn as_str(&self) -> &str {
&self.0
}
}
impl std::fmt::Display for LocusId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
}
}
impl From<String> for LocusId {
fn from(s: String) -> Self {
Self(s)
}
}
impl From<&str> for LocusId {
fn from(s: &str) -> Self {
Self(s.to_string())
}
}
impl AsRef<str> for LocusId {
fn as_ref(&self) -> &str {
&self.0
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct BearerId(pub String);
impl BearerId {
pub fn new(s: impl Into<String>) -> Self {
Self(s.into())
}
pub fn as_str(&self) -> &str {
&self.0
}
}
impl std::fmt::Display for BearerId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
}
}
impl From<String> for BearerId {
fn from(s: String) -> Self {
Self(s)
}
}
impl From<&str> for BearerId {
fn from(s: &str) -> Self {
Self(s.to_string())
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(tag = "kind", content = "id", rename_all = "kebab-case")]
pub enum OverrideScope {
Vault(VaultId),
Locus(LocusId),
Bearer(BearerId),
}