domani/src/domain.rs

33 lines
775 B
Rust
Raw Normal View History

pub mod acme;
pub mod checker;
2023-07-09 13:08:33 +00:00
mod config;
pub mod manager;
mod name;
pub mod store;
2023-07-09 13:08:33 +00:00
pub use config::*;
pub use name::*;
use crate::error::unexpected::{self, Mappable};
use crate::origin;
use hex::ToHex;
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
/// Defines how a domain will behave when it is accessed. These are configured by the owner of the
/// domain during setup.
pub struct Settings {
#[serde(flatten)]
pub origin_descr: origin::Descr,
}
impl Settings {
pub fn hash(&self) -> Result<String, unexpected::Error> {
let mut h = Sha256::new();
serde_json::to_writer(&mut h, self).or_unexpected()?;
Ok(h.finalize().encode_hex::<String>())
}
}