Skip to main content

cynic_parser/executable/generated/
descriptions.rs

1use super::prelude::*;
2use super::{
3    ExecutableId,
4    ids::{DescriptionId, StringLiteralId},
5    strings::StringLiteral,
6};
7#[allow(unused_imports)]
8use std::fmt::{self, Write};
9
10pub struct DescriptionRecord {
11    pub literal: StringLiteralId,
12    pub span: Span,
13}
14
15#[derive(Clone, Copy)]
16pub struct Description<'a>(pub(in super::super) ReadContext<'a, DescriptionId>);
17
18impl<'a> Description<'a> {
19    pub fn literal(&self) -> StringLiteral<'a> {
20        let document = self.0.document;
21        document.read(document.lookup(self.0.id).literal)
22    }
23    pub fn span(&self) -> Span {
24        let document = self.0.document;
25        document.lookup(self.0.id).span
26    }
27}
28
29impl Description<'_> {
30    pub fn id(&self) -> DescriptionId {
31        self.0.id
32    }
33}
34
35impl fmt::Debug for Description<'_> {
36    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37        f.debug_struct("Description")
38            .field("literal", &self.literal())
39            .field("span", &self.span())
40            .finish()
41    }
42}
43
44impl ExecutableId for DescriptionId {
45    type Reader<'a> = Description<'a>;
46    fn read(self, document: &ExecutableDocument) -> Self::Reader<'_> {
47        Description(ReadContext { id: self, document })
48    }
49}
50
51impl IdReader for Description<'_> {
52    type Id = DescriptionId;
53    type Reader<'a> = Description<'a>;
54    fn new(id: Self::Id, document: &'_ ExecutableDocument) -> Self::Reader<'_> {
55        document.read(id)
56    }
57}