1use crate::diag::{ByteSpan, DiagCode};
4
5#[derive(Clone, Debug, PartialEq, Eq)]
6pub struct Location {
7 pub path: String,
8 pub span: ByteSpan,
9 pub start: Option<(usize, usize)>,
11}
12
13#[derive(Clone, Debug, PartialEq, Eq)]
16pub struct Refusal {
17 pub at: Location,
18 pub code: DiagCode,
19 pub reason: String,
20}
21
22impl Refusal {
23 pub fn new(
24 path: impl Into<String>,
25 span: ByteSpan,
26 code: DiagCode,
27 reason: impl Into<String>,
28 ) -> Refusal {
29 Refusal {
30 at: Location {
31 path: path.into(),
32 span,
33 start: None,
34 },
35 code,
36 reason: reason.into(),
37 }
38 }
39
40 pub fn placed(mut self, start: (usize, usize)) -> Refusal {
41 self.at.start = Some(start);
42 self
43 }
44}