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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
//! The Bahá’í Sacred Writings for use in Rust projects and APIs.
//!
//! # Source
//!
//! All of the Writings are downloaded directly from <https://www.bahai.org/library>.
//! The downloaded HTML is included in the `html` folder.
//!
//! # Structure
//!
//! Each type of Writings has its own struct, e.g. `HiddenWord`, `PrayerParagraph`,
//! and `GleaningsParagraph`, which are hopefully explanatory of the unit the struct
//! represents. In this way, an excerpt from the Writings can be precisely referenced.
//!
//! The `ref_id` in each struct represents the exact reference ID at which the struct
//! points to at <https://www.bahai.org/r/`ref_id`>. For example, Persian Hidden Word #3
//! can be accessed directly at <https://www.bahai.org/r/607855955>. Hence, its struct
//! will have `ref_id` == "`607855955`". This is a `String`, **not** a `u32` or other
//! integer type, because www.bahai.org currently requires leading zeroes, and to ensure
//! future compatibility, it is not assumed integers of a fixed length will always be used.
//!
//! The `text` field of each struct is the exact plain text as extracted from the downloaded HTML.
//!
//! Other fields of each struct have their own documentation, depending on the type.
//!
//! # Usage
//!
//! ## Embed All
//!
//! When `::all()` is invoked on one of the structs implementing the `EmbedAllTrait`,
//! the HTML for that Work is parsed into the relevant structs once (very fast)
//! and stored in a `LazyLock<T>`.
//!
//! ## Example: Hidden Words
//!
//! ```
//! use writings::{HiddenWord, HiddenWordKind, EmbedAllTrait as _};
//!
//! let hw = HiddenWord::all()
//! .iter()
//! .find(|hw| hw.kind == HiddenWordKind::Persian && hw.number == Some(37))
//! .cloned()
//! .unwrap();
//!
//! assert_eq!(
//! hw,
//! HiddenWord {
//! ref_id: "998408191".to_string(),
//! kind: HiddenWordKind::Persian,
//! number: Some(37),
//! prelude: Some(concat!("In the first line of the Tablet it is recorded and written,",
//! " and within the sanctuary of the tabernacle of God is hidden:").to_string()),
//! invocation: Some("O My Servant!".to_string()),
//! text: concat!("Abandon not for that which perisheth an everlasting dominion,",
//! " and cast not away celestial sovereignty for a worldly desire. This is the river",
//! " of everlasting life that hath flowed from the wellspring of the pen of the merciful;",
//! " well is it with them that drink!").to_string(),
//! }
//! );
//! ```
//!
//! ## Example: Gleanings
//!
//! ```
//! use writings::{GleaningsParagraph, EmbedAllTrait as _};
//!
//! let gleanings = GleaningsParagraph::all()
//! .iter()
//! .filter(|hw| hw.text.contains("all things visible and invisible"))
//! .cloned()
//! .collect::<Vec<_>>();
//!
//! assert_eq!(gleanings.len(), 3);
//!
//! let results = gleanings.iter().map(|g| (g.number, g.roman.as_str(), g.paragraph)).collect::<Vec<_>>();
//! assert_eq!(results, vec![
//! (11, "XI", 3),
//! (49, "XLIX", 1),
//! (90, "XC", 2),
//! ]);
//!
//! assert!(gleanings[0].text.starts_with(concat!("No sooner had her voice reached that most exalted Spot",
//! " than We made reply: “Render thanks unto thy Lord, O Carmel. The fire of thy separation from Me was",
//! " fast consuming thee, when the ocean of My presence surged before thy face, cheering thine eyes and",
//! " those of all creation, and filling with delight all things visible and invisible.")));
//! ```
//!
//! ## Example: Prayers
//!
//! ```
//! use writings::{PrayerKind, PrayerParagraph, EmbedAllTrait as _};
//!
//! let prayer = PrayerParagraph::all()
//! .iter()
//! .find(|p| {
//! p.kind == PrayerKind::General
//! && p.section
//! .iter()
//! .any(|s| s.contains("Western States")
//! && p.paragraph == 2)
//! })
//! .cloned()
//! .unwrap();
//!
//! assert_eq!(
//! &prayer.text,
//! concat!(
//! "O God! O God! This is a broken-winged bird and his flight is very slow—assist him so that he may",
//! " fly toward the apex of prosperity and salvation, wing his way with the utmost joy and happiness",
//! " throughout the illimitable space, raise his melody in Thy Supreme Name in all the regions,",
//! " exhilarate the ears with this call, and brighten the eyes by beholding the signs of guidance."
//! )
//! );
//! ```
//!
//! # Languages
//!
//! Currently, only English is available in this crate. If reliable authoritative
//! sources can be found for other languages, it is hoped they will be added.
//! عربي (Arabic) and فارسی (Farsi / Persian) will be added if there is demand and
//! someone versed in these languages can help ensure the accuracy of the implementation.
//!
//! TODO: More docs...
//!
//! License: MIT AND Bahá’í International Community License
pub use ;
pub use ;
pub use ;
pub use MeditationParagraph;
pub use GleaningsParagraph;
pub use ;
pub use ;
pub use EmbedAllTrait;
use WritingsTrait;
pub use ;
use ;
use Display;
use ;
use Error;
/// Allows enumeration of all Writings types in the crate.
/// See also the discriminants of this enum for use in APIs, etc.: [`WritingsType`]
/// A "footnote" or "endnote" embedded in a Text.
/// Whether the struct text represents an invocation ("In the name of God, the Most Glorious!"),
/// an instruction to the reader, or "normal" text.
/// Alias for [`Result`] with [`WritingsError`] as the Error type.
pub type WritingsResult<T> = ;
/// An error type specific for this crate.