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
//! `bem` is a Rust crate that provides a simple and intuitive interface to work with BEM (Block Element Modifier) notation.
//! It includes functions to parse BEM blocks, elements, and their modifiers, and to convert them to and from JSON representation.
//!
//! With this crate, you can easily serialize and deserialize BEM structures in your Rust applications,
//! making it an excellent choice for web developers, CSS authors, and anyone working with BEM-based design.
//!
//! # Features
//!
//! - **Parse BEM Notation**: Use the `parse` function to interpret BEM strings and create corresponding Rust structures.
//! - **JSON Serialization and Deserialization**: Convert BEM blocks to JSON strings and vice versa with the `to_json` and `from_json` functions.
//! - **Customizable Models**: Work with `BEMBlock` and `BEMElement` structs to represent BEM structures, supporting custom modifiers and elements.
//!
//! # Quick Start
//!
//! Add the crate to your Cargo.toml and start working with BEM structures right away!
//!
//! ```
//! use bem::{BEMBlock, to_json, from_json};
//!
//! let bem_block = BEMBlock { name: "media-player".to_string(), modifiers: vec![], elements: vec![] };
//! let json = to_json(&bem_block).unwrap();
//! let bem_block_from_json = from_json(&json).unwrap();
//! ```
//!
//! Please see the individual function and structure documentation for detailed information and examples.
pub use ;
pub use parse;
/// Converts a `BEMBlock` into a JSON string.
///
/// This function takes a reference to a `BEMBlock` and serializes it into a JSON string.
/// It returns a `Result` containing the JSON string if the conversion is successful, or
/// a `serde_json::Error` if there is a problem during serialization.
///
/// # Arguments
///
/// * `bem_block`: &BEMBlock - A reference to the `BEMBlock` to be converted to JSON.
///
/// # Returns
///
/// * `Result<String, serde_json::Error>` - A result containing the JSON string or an error.
///
/// # Examples
///
/// ```
/// use bem::{BEMBlock, to_json};
///
/// let bem_block = BEMBlock { name: "media-player".to_string(), modifiers: vec![], elements: vec![] };
/// let json = to_json(&bem_block).unwrap();
/// ```
/// Converts a `BEMBlock` into a pretty-printed JSON string.
///
/// This function takes a reference to a `BEMBlock` and serializes it into a prett-printed JSON string.
/// It returns a `Result` containing the pretty-printed JSON string if the conversion is successful, or
/// a `serde_json::Error` if there is a problem during serialization.
///
/// # Arguments
///
/// * `bem_block`: &BEMBlock - A reference to the `BEMBlock` to be converted to JSON.
///
/// # Returns
///
/// * `Result<String, serde_json::Error>` - A result containing the pretty-printed JSON string or an error.
///
/// # Examples
///
/// ```
/// use bem::{BEMBlock, to_json_pretty};
///
/// let bem_block = BEMBlock { name: "media-player".to_string(), modifiers: vec![], elements: vec![] };
/// let json = to_json_pretty(&bem_block).unwrap();
/// ```
/// Converts a JSON string into a `BEMBlock`.
///
/// This function takes a JSON string and deserializes it into a `BEMBlock`.
/// It returns a `Result` containing the `BEMBlock` if the conversion is successful, or
/// a `serde_json::Error` if there is a problem during deserialization.
///
/// # Arguments
///
/// * `json`: &str - The JSON string to be converted to a `BEMBlock`.
///
/// # Returns
///
/// * `Result<BEMBlock, serde_json::Error>` - A result containing the `BEMBlock` or an error.
///
/// # Examples
///
/// ```
/// use bem::{BEMBlock, from_json};
///
/// let json = "{\"name\":\"media-player\",\"modifiers\":[],\"elements\":[]}";
/// let bem_block = from_json(json).unwrap();
/// ```