graphql_composition/
diagnostics.rs1#[derive(Default, Debug)]
3pub struct Diagnostics(Vec<Diagnostic>);
4
5impl Diagnostics {
6 pub(crate) fn any_fatal(&self) -> bool {
7 self.0.iter().any(|diagnostic| diagnostic.is_fatal)
8 }
9
10 pub(crate) fn clone_all_from(&mut self, other: &Diagnostics) {
11 self.0.extend(other.0.iter().cloned())
12 }
13
14 pub fn iter_messages(&self) -> impl Iterator<Item = &str> {
16 self.0.iter().map(|diagnostic| diagnostic.message.as_str())
17 }
18
19 pub(crate) fn push_fatal(&mut self, message: String) {
20 self.0.push(Diagnostic {
21 message,
22 is_fatal: true,
23 });
24 }
25
26 pub(crate) fn push_warning(&mut self, message: String) {
27 self.0.push(Diagnostic {
28 message,
29 is_fatal: false,
30 });
31 }
32}
33
34#[derive(Debug, Clone)]
36pub(crate) struct Diagnostic {
37 message: String,
38 is_fatal: bool,
40}