1use crate::artifact_mgmt::user::ScriptDetail;
5use crate::logical::hex_digest;
6
7pub const STALE_SCRIPT: &str = "the script changed since it was loaded; reload it";
9
10#[must_use]
12pub fn is_enabled(tag: Option<&str>) -> bool {
13 tag != Some("false")
14}
15
16#[must_use]
18pub fn script_revision(name: Option<&str>, source: Option<&str>, enabled: bool) -> String {
19 hex_digest(vec![format!("script {:?}", (name, source, enabled))])
20}
21
22impl ScriptDetail {
23 #[must_use]
25 pub fn revision(&self) -> String {
26 script_revision(
27 self.name.as_deref(),
28 self.source.as_deref(),
29 is_enabled(self.enabled.as_deref()),
30 )
31 }
32}