Lines
100 %
Functions
Branches
//! A stored script as the script-edit form holds it, with the revision
//! digesting its editable fields.
use crate::artifact_mgmt::user::ScriptDetail;
use crate::logical::hex_digest;
/// The error text of a script edit whose expected revision no longer matches.
pub const STALE_SCRIPT: &str = "the script changed since it was loaded; reload it";
/// Whether an `enabled` tag value leaves the script on: only `false` turns it off.
#[must_use]
pub fn is_enabled(tag: Option<&str>) -> bool {
tag != Some("false")
}
/// Digest of the script's name, source and enabled state.
pub fn script_revision(name: Option<&str>, source: Option<&str>, enabled: bool) -> String {
hex_digest(vec![format!("script {:?}", (name, source, enabled))])
impl ScriptDetail {
/// The revision an edit of this script must carry.
pub fn revision(&self) -> String {
script_revision(
self.name.as_deref(),
self.source.as_deref(),
is_enabled(self.enabled.as_deref()),
)