use super::model::SourceReference;
pub(crate) const HANDLE_PREFIX: &str = "ctx://source/";
#[must_use]
pub(crate) fn handle_for(content_hash: u64) -> String {
format!("{HANDLE_PREFIX}{content_hash}")
}
#[must_use]
pub(crate) fn parse_handle(handle: &str) -> Option<u64> {
handle.strip_prefix(HANDLE_PREFIX)?.parse().ok()
}
#[must_use]
pub(crate) fn source_for(fragment_id: u64, content_hash: u64) -> SourceReference {
SourceReference {
fragment_id,
handle: handle_for(content_hash),
memory_id: None,
}
}
#[cfg(test)]
#[path = "provenance_tests.rs"]
mod tests;