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