2025-03-29 16:06:11 -04:00
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
pub struct Reference {
|
|
|
|
object_id: String,
|
2025-03-30 15:02:46 -04:00
|
|
|
content_address: String,
|
2025-03-29 16:06:11 -04:00
|
|
|
path: String,
|
|
|
|
#[serde(skip_serializing_if = "Vec::is_empty")]
|
|
|
|
dependents: Vec<Rc<Reference>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Reference {
|
2025-03-30 15:02:46 -04:00
|
|
|
pub fn new(object_id: String, content_address: String, path: String) -> Self {
|
2025-03-29 16:06:11 -04:00
|
|
|
Self {
|
|
|
|
object_id,
|
2025-03-30 15:02:46 -04:00
|
|
|
content_address,
|
2025-03-29 16:06:11 -04:00
|
|
|
path,
|
|
|
|
dependents: Vec::new(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn add_dep(mut self, dep: Rc<Reference>) -> Self {
|
|
|
|
self.dependents.push(dep);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn to_rc(self) -> Rc<Self> {
|
|
|
|
Rc::new(self)
|
|
|
|
}
|
|
|
|
}
|