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
51
52
53
54
55
56
57
58
59
60
61
//! Raoh turns untyped boundary input into typed domain values.
//!
//! It follows parse, don't validate: a domain value is built only once everything it is built
//! from has been read, so a value that exists is a valid one. What was wrong with the input comes
//! back as [`Issues`], every one of them with the [JSON Pointer](Pointer) of where it was found,
//! rather than the first.
//!
//! Serde reads JSON text into a [`serde_json::Value`]; Raoh reads that value into the domain.
//!
//! ```
//! use raoh::json::prelude::*;
//!
//! #[derive(Debug)]
//! struct Email(String);
//! #[derive(Debug)]
//! struct User { email: Email, age: u32 }
//!
//! fn email() -> impl Decoder<Value, Output = Email> {
//! string().trim().lowercase().email().map(Email)
//! }
//!
//! fn user() -> impl Decoder<Value, Output = User> {
//! object((
//! field("email", email()),
//! field("age", u32().range(0..=150)),
//! ))
//! .map(|(email, age)| User { email, age })
//! }
//!
//! let issues = user().decode(&json!({"email": "nope", "age": 200})).unwrap_err();
//! let paths: Vec<String> = issues.iter().map(|i| i.path().to_string()).collect();
//! assert_eq!(paths, ["/email", "/age"]);
//! ```
//!
//! Independent parts are combined with a tuple, which reports the issues of every part;
//! [`Decoder::and_then`] checks what depends on several parts together, once they have all been
//! read.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Presence;
;
pub use ;