Lines
100 %
Functions
Branches
//! A stored template as the template-edit form holds it, with the revision
//! digesting its editable fields.
use crate::artifact_mgmt::user::TemplateDetail;
use crate::logical::hex_digest;
/// The error text of a template edit whose expected revision no longer matches.
pub const STALE_TEMPLATE: &str = "the template changed since it was loaded; reload it";
/// Digest of the template's name and source.
#[must_use]
pub fn template_revision(name: Option<&str>, source: &str) -> String {
hex_digest(vec![format!("template {:?}", (name, source))])
}
impl TemplateDetail {
/// The revision an edit of this template must carry.
pub fn revision(&self) -> String {
template_revision(self.name.as_deref(), &self.source_text)