@@ -21,6 +21,7 @@ pub enum TScalarStyle {
21
21
Foled ,
22
22
}
23
23
24
+ /// A location in a yaml document.
24
25
#[ derive( Clone , Copy , PartialEq , Debug , Eq ) ]
25
26
pub struct Marker {
26
27
index : usize ,
@@ -33,29 +34,34 @@ impl Marker {
33
34
Marker { index, line, col }
34
35
}
35
36
37
+ /// Return the index (in bytes) of the marker in the source.
36
38
#[ must_use]
37
39
pub fn index ( & self ) -> usize {
38
40
self . index
39
41
}
40
42
43
+ /// Return the line of the marker in the source.
41
44
#[ must_use]
42
45
pub fn line ( & self ) -> usize {
43
46
self . line
44
47
}
45
48
49
+ /// Return the column of the marker in the source.
46
50
#[ must_use]
47
51
pub fn col ( & self ) -> usize {
48
52
self . col
49
53
}
50
54
}
51
55
56
+ /// An error that occured while scanning.
52
57
#[ derive( Clone , PartialEq , Debug , Eq ) ]
53
58
pub struct ScanError {
54
59
mark : Marker ,
55
60
info : String ,
56
61
}
57
62
58
63
impl ScanError {
64
+ /// Create a new error from a location and an error string.
59
65
#[ must_use]
60
66
pub fn new ( loc : Marker , info : & str ) -> ScanError {
61
67
ScanError {
@@ -64,10 +70,17 @@ impl ScanError {
64
70
}
65
71
}
66
72
73
+ /// Return the marker pointing to the error in the source.
67
74
#[ must_use]
68
75
pub fn marker ( & self ) -> & Marker {
69
76
& self . mark
70
77
}
78
+
79
+ /// Return the information string describing the error that happened.
80
+ #[ must_use]
81
+ pub fn info ( & self ) -> & str {
82
+ self . info . as_ref ( )
83
+ }
71
84
}
72
85
73
86
impl Error for ScanError {
0 commit comments