origin-secrets 0.2.0

SecretStore contract for Origin, with an in-memory implementation and a shared contract test suite.
Documentation
use serde::{Deserialize, Serialize};
use std::fmt;

/// Addresses one secret.
///
/// `namespace` maps to the "service" concept of the platform keychains, `name` to the
/// account entry within it.
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
pub struct SecretKey {
    namespace: String,
    name: String,
}

impl SecretKey {
    pub fn new(namespace: impl Into<String>, name: impl Into<String>) -> Self {
        Self {
            namespace: namespace.into(),
            name: name.into(),
        }
    }

    pub fn namespace(&self) -> &str {
        &self.namespace
    }

    pub fn name(&self) -> &str {
        &self.name
    }
}

impl fmt::Display for SecretKey {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}/{}", self.namespace, self.name)
    }
}