sylt_common/
blob.rs

1use std::collections::HashMap;
2
3use crate::Type;
4
5// TODO(ed): We need to rewrite this with indexes to this struct instead
6// of an RC - otherwise we cannot support all recursive types.
7#[derive(Debug, Clone)]
8pub struct Blob {
9    pub id: usize,
10    pub namespace: usize,
11    pub name: String,
12    /// Maps field names to their type
13    pub fields: HashMap<String, Type>,
14}
15
16impl PartialEq for Blob {
17    fn eq(&self, other: &Self) -> bool {
18        self.id == other.id
19    }
20}
21
22impl Blob {
23    pub fn new(id: usize, namespace: usize, name: &str) -> Self {
24        Self {
25            id,
26            namespace,
27            name: String::from(name),
28            fields: HashMap::new(),
29        }
30    }
31}