31 lines
610 B
Rust
Raw Normal View History

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,
path: String,
#[serde(skip_serializing_if = "Vec::is_empty")]
dependents: Vec<Rc<Reference>>,
}
impl Reference {
pub fn new(object_id: String, path: String) -> Self {
Self {
object_id,
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)
}
}