cynic_parser/values/
mod.rs1mod const_lists;
2mod const_objects;
3mod const_value;
4mod enums;
5mod lists;
6mod objects;
7mod scalars;
8mod value;
9mod variables;
10
11pub mod ids;
12pub mod iter;
13pub mod writer;
14
15use std::sync::Arc;
16
17pub use self::{
18 const_lists::ConstList,
19 const_objects::{ConstObject, ConstObjectField},
20 const_value::ConstValue,
21 enums::EnumValue,
22 iter::Iter,
23 lists::List,
24 objects::{Object, ObjectField},
25 scalars::{BooleanValue, FloatValue, IntValue, NullValue, StringValue},
26 value::Value,
27 variables::VariableValue,
28};
29
30use ids::*;
31use indexmap::IndexSet;
32
33pub mod storage {
34 pub use super::{
35 objects::FieldRecord,
36 value::{ValueKind, ValueRecord},
37 };
38}
39
40#[derive(Default)]
41pub struct ValueStore {
42 strings: Arc<IndexSet<Box<str>>>,
43
44 values: Vec<storage::ValueRecord>,
45
46 fields: Vec<storage::FieldRecord>,
47}
48
49impl ValueStore {
50 pub fn read<T>(&self, id: T) -> T::Reader<'_>
51 where
52 T: ValueStoreId,
53 {
54 id.read(self)
55 }
56}
57
58#[derive(Clone, Copy)]
59struct Cursor<'a, I> {
60 id: I,
61 store: &'a ValueStore,
62}
63
64pub trait ValueStoreId: Copy {
65 type Reader<'a>;
66
67 fn read(self, store: &ValueStore) -> Self::Reader<'_>;
68}