use super::*;
use crate::core::NormalizedPath;
use serde::Serialize;
use std::sync::Arc;
mod artifact_payload;
mod clear;
mod daemon_status;
mod ephemeral;
mod fingerprint;
mod generic_exec;
mod rust_artifacts;
mod session_lifecycle;
mod session_stats;
mod variant_indices;
pub(super) fn roundtrip<
T: Serialize + serde::de::DeserializeOwned + PartialEq + std::fmt::Debug,
>(
val: &T,
) {
let bytes = bincode::serialize(val).unwrap();
let decoded: T = bincode::deserialize(&bytes).unwrap();
assert_eq!(*val, decoded);
}
pub(super) fn variant_index<T: Serialize>(val: &T) -> u32 {
let bytes = bincode::serialize(val).unwrap();
u32::from_le_bytes(bytes[0..4].try_into().unwrap())
}
pub(super) fn sample_session_stats() -> SessionStats {
SessionStats {
duration_ms: 1,
compilations: 2,
hits: 3,
misses: 4,
non_cacheable: 5,
errors: 6,
errors_cached: 7,
time_saved_ms: 8,
unique_sources: 9,
bytes_read: 10,
bytes_written: 11,
phase_profile: None,
}
}
pub(super) fn sample_daemon_status() -> DaemonStatus {
DaemonStatus {
version: "1.0.0".to_string(),
daemon_namespace: "default".to_string(),
endpoint: "test-endpoint".to_string(),
private_daemon: PrivateDaemonStatus::shared(),
artifact_count: 1,
cache_size_bytes: 2,
metadata_entries: 3,
uptime_secs: 4,
cache_hits: 5,
cache_misses: 6,
total_compilations: 7,
non_cacheable: 8,
compile_errors: 9,
compile_errors_cached: 10,
time_saved_ms: 11,
total_links: 12,
link_hits: 13,
link_misses: 14,
link_non_cacheable: 15,
dep_graph_contexts: 16,
dep_graph_files: 17,
sessions_total: 18,
sessions_active: 19,
cache_dir: "/tmp/zccache".into(),
dep_graph_version: 20,
dep_graph_disk_size: 21,
dep_graph_persisted: true,
}
}
pub(super) fn sample_artifact() -> ArtifactData {
ArtifactData {
outputs: vec![ArtifactOutput {
name: "out.o".to_string(),
payload: ArtifactPayload::Bytes(Arc::new(b"object".to_vec())),
}],
stdout: Arc::new(Vec::new()),
stderr: Arc::new(Vec::new()),
exit_code: 0,
}
}
const _: () = assert!(super::super::PROTOCOL_VERSION > 0);
const _FINGERPRINT_VERSION: () = assert!(super::super::PROTOCOL_VERSION == 15);