1#![cfg_attr(docsrs, feature(doc_cfg))]
17#![cfg_attr(docsrs, doc(auto_cfg))]
18mod compact_iri;
19mod compare;
20pub mod container;
22pub mod context;
24mod direction;
25mod error;
26mod expandable;
27pub mod hash;
28pub mod intern;
29mod into_json;
30mod keyword;
31mod lang;
32mod nullable;
33mod print_ld;
34mod try_from_json;
35mod utils;
36
37pub use compact_iri::*;
38pub use compare::*;
39pub use container::{Container, ContainerKind};
40pub use context::{Context, ContextDocument, ContextEntry};
41pub use direction::*;
42pub use error::*;
43pub use expandable::*;
44pub use into_json::*;
45pub use jstrict::{
46 BorrowUnordered,
47 Kind,
48 Number,
49 NumberBuf,
50 Object,
51 Parse,
52 Print,
53 String,
54 Unordered,
55 UnorderedEq,
56 UnorderedHash,
57 UnorderedPartialEq,
58 Value,
59 object,
60 parse,
61 print,
62};
63pub use keyword::*;
64pub use lang::*;
65pub use nullable::*;
66pub use try_from_json::*;
67
68#[cfg(feature = "serde")]
69pub use jstrict::{from_value, to_value};
70
71#[derive(Clone, Copy, Debug)]
72pub struct Unexpected(jstrict::Kind, &'static [jstrict::Kind]);
74
75impl Unexpected {
76 #[must_use]
78 pub fn found(&self) -> jstrict::Kind {
79 self.0
80 }
81
82 #[must_use]
84 pub fn expected(&self) -> &'static [jstrict::Kind] {
85 self.1
86 }
87}
88
89impl std::fmt::Display for Unexpected {
90 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
91 write!(f, "unexpected {}, expected ", self.0)?;
92 for (i, kind) in self.1.iter().enumerate() {
93 if i > 0 {
94 f.write_str(" or ")?;
95 }
96 write!(f, "{kind}")?;
97 }
98 Ok(())
99 }
100}
101
102impl std::error::Error for Unexpected {}