blob: 1e1b433cd2be0e314559597fc54568b82426179d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// License: MPL-2.0
// (c) 2022 Drew DeVault <sir@cmpwn.com>
use fmt;
use io;
// An invalid JSON token was encountered at this location (line, column).
export type invalid = !(uint, uint);
// The maximum nesting limit was reached.
export type limitreached = !void;
// A tagged union of all possible errors returned from this module.
export type error = !(invalid | limitreached | io::error);
// The JSON null value.
export type _null = void;
// The '[' token, signaling the start of a JSON array.
export type arraystart = void;
// The ']' token, signaling the end of a JSON array.
export type arrayend = void;
// The '{' token, signaling the start of a JSON object.
export type objstart = void;
// The '}' token, signaling the end of a JSON object.
export type objend = void;
// The ':' token.
export type colon = void;
// The ',' token.
export type comma = void;
// All tokens which can be returned from the JSON tokenizer.
export type token = (arraystart | arrayend | objstart |
objend | colon | comma | str | f64 | bool | _null);
// Converts an [[error]] into a human-friendly string.
export fn strerror(err: error) const str = {
static let buf: [53]u8 = [0...];
match (err) {
case let err: invalid =>
return fmt::bsprintf(buf,
"{}:{}: Invalid JSON token encountered", err.0, err.1);
case let err: io::error =>
return io::strerror(err);
};
};
|