use std::sync::Arc; use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Reference { pub object_id: String, pub content_address: String, pub path: String, #[serde(skip_serializing_if = "Vec::is_empty")] pub dependents: Vec>, } impl Reference { pub fn new(object_id: String, content_address: String, path: String) -> Self { Self { object_id, content_address, path, dependents: Vec::new(), } } pub fn add_dep(mut self, dep: Arc) -> Self { self.dependents.push(dep); self } pub fn to_arc(self) -> Arc { Arc::new(self) } pub fn is_leaf(&self) -> bool { return self.dependents.is_empty(); } }