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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
//! [](https://gitlab.nebula.technology/libraries/rust/gearbox/-/commits/main)
//! [](https://gitlab.nebula.technology/libraries/rust/gearbox/-/commits/main)
//! [](https://gitlab.nebula.technology/libraries/rust/gearbox/-/releases)
//!
//! Gearbox is a versatile library that encompasses a wide array of functionalities, including networking, logging,
//! railway-oriented programming extensions, and time management. Initially designed as a collection of utilities, the
//! ultimate vision for Gearbox is to evolve into a highly optimized, standalone toolkit. The goal is to minimize external
//! dependencies progressively, leading to a library that is lightweight and efficient. By doing so, Gearbox aims to be
//! universally compatible, from embedded systems to WebAssembly (WASM) environments, all while maintaining simplicity and
//! minimizing the need for boilerplate code. This development strategy positions Gearbox as a comprehensive solution for
//! developers seeking to build efficient, scalable applications across a broad spectrum of platforms.
//!
//! # Features
//!
//! | Category | Feature | use | Description | Status |
//! |------------|-----------------------|-----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|
//! | Common | TryDefault | gearbox::common::TryDefault | This is a trait used internally in `Gearbox` defining a `TryDefault` trait that returns a Result<T,Self::Error>. It can also be used in other systems. | ✅ |
//! | | BoxedFuture | gearbox::common::BoxedFuture | Type alias for a pinned boxed future. Used for returning dynamically dispatched futures. | ✅ |
//! | Error | ErrorTracer | gearbox::error::tracer::* | An error structure that builds a traceable stack of errors. It allows breaking down the error into a TypeId to define the encapsulated error for further operations. Contains information about file, line, module path, and optional error_code with display and debug. This also comes with the macro `Error!()` which sets up the `ErrorTracerExtInfo` with all the needed information (file, line, module). | ⚠️ |
//! | | Rail ErrorTracer | gearbox::rails::ext::map_err_tracer | Simplification for `map_err` for operating with the ErrorTracer, allowing for passing an `Error!()` or an `ErrorTracerExtInfo` for collecting all the information. | ✅ |
//! | Logging | Tracing Log Formatter | gearbox::log::fmt::* | Custom subscriber for formatting logs when using the rust Tracing library. | ⚠️ |
//! | Networking | hostname | gearbox::net::hostname | Get the hostname of the local machine. | ✅ |
//! | | HTTP Request | gearbox::net::http::request | Send an HTTP request. This is an extension on top of `Reqwest` that simplifies the implementation of mTLS and payload signing. | ⚠️ |
//! | | HTTP Request Chaining | gearbox::net::http::request_chain | Chaining system for HTTP requests, allowing for chaining requests and responses for more advanced request/response handling. | ❌ |
//! | Paths | Common Paths | gearbox::path::* | Common paths under Windows, Linux, and more. For example, under Linux, the config path is usually `~/.config/`. | ✅ |
//! | Rails | Common Extensions | gearbox::rails::ext::* | Various extension traits for operating on `Result`, `Option`, and other standard types, providing additional methods for error handling, merging results, and tapping into values. | ⚠️ |
//! | | Future Extensions | gearbox::rails::ext::future::* | Extensions for working with `Future` types, providing methods for mapping, chaining, and merging futures. | ✅ |
//! | serde | Dynamic Serialization | gearbox::serde::dynamic::* | Dynamic serialization system that allows for encoding and decoding of multiple formats. This is a simplified version of the serde library. | ⚠️ |
//! | | Wasm Bindgen Ser/de | gearbox::serde::wasm_bindgen::* | Implementation for WASM Bind Generator that allows for serialization/deserialization of JsValue. | ✅ |
//! | Storage | Web Storage | gearbox::storage::web::local_storage::* | Interface for interacting with local storage in a web environment, including features for setting, getting, and deleting data with JSON serialization/deserialization support. | 🚧 |
//! | | File Storage | gearbox::storage::io::file::* | Interface for interacting with file storage, including features for setting, getting, and deleting data with JSON and YAML serialization/deserialization support. | 🧪 |
//! | | Selective Storage | gearbox::storage::selective_storage | Trait for selective storage operations, providing methods for creating, setting, getting, and deleting storage entries. | 🚧 |
//! | Time | Time Stamps and more | gearbox::time::* | Timestamp system similar to Chrono, handling times and time calculations. Used throughout Gearbox instead of Chrono. | ⚠️ |
//! | Template | Template Engine | gearbox::template::* | Template engine responsible for rendering templates using context data and applying pipelines for data transformations. It supports pipelines for operations like date formatting and string prefixing. | ⚠️ |
//!
//! ### Status Icons Explanation
//!
//! - ✅ Completed: The feature is fully implemented and tested.
//! - ❌ Not Completed: The feature is not implemented.
//! - ⚠️ Partially: The feature is partially implemented.
//! - 🚧 In Development: The feature is currently being developed.
//! - 🧪 Missing Testing: The feature is implemented but lacks testing.
//!
//! # Test Status
//! [See Test Status](./TEST_STATUS.md)
//!
//!
//! # Http Request (gearbox::net::http::request)
//!
//! ## Complete architectural overview:
//! ```mermaid
//! classDiagram
//! %% Package: request
//! namespace request {
//! class Client {
//! +client: reqwest::Client
//! +new()
//! +with_client(reqwest::Client)
//! +set_global_signing(Signature)
//! }
//!
//! class Error {
//! +UrlParser(ParseError)
//! +Request(reqwest::Error)
//! +NoUrl
//! +HeaderValue(reqwest::header::InvalidHeaderValue)
//! +DeserializeContentType(String)
//! +DeserializeJson(serde_json::Error)
//! +BodyError(TracerError)
//! }
//!
//! class Method {
//! <<enumeration>>
//! Get
//! Post
//! Put
//! Delete
//! Patch
//! Head
//! Options
//! Connect
//! Trace
//! None
//! }
//!
//! class RequestBuilder {
//! +client: Option<Arc<Client>>
//! +method: Method
//! +uri: Option<Url>
//! +headers: HeaderMap
//! +body: Body
//! +content_type: String
//! +signature: Option<Signature>
//! +new_with_client(client: Option<Client>, method: Method, uri: Url)
//! +method(T: Into<Method>)
//! +uri(uri: &str)
//! +header(H: Into<Header>)
//! +headers(H: Into<HeaderMap>)
//! +body(B: Into<Body>)
//! +content_type(content_type: &str)
//! +with_signing_default()
//! +with_signing(signature: Signature)
//! +send()
//! }
//!
//! class Response {
//! +status: StatusCode
//! +headers: HeaderMap
//! +content_length: Option<u64>
//! +url: Url
//! +body: BodyOwned
//! +status()
//! +to(T: DeserializeOwned)
//! }
//!
//! class StatusCode {
//! +code: u16
//! +reason: &'static str
//! +as_u16()
//! +as_str()
//! }
//!
//! class Url {
//! +Simple(url: String)
//! }
//!
//! class Body {
//! +Empty
//! }
//!
//! class BodyOwned {
//! +from(box_raw: Box<reqwest::Response>)
//! }
//! }
//!
//! %% Relationships
//! Client --> RequestBuilder
//! RequestBuilder --> Response
//! RequestBuilder --> Error
//! Response --> StatusCode
//! Response --> HeaderMap
//! Response --> Url
//! Response --> BodyOwned
//! HeaderMap --> Header
//! Header --> Name
//! Header --> Values
//! Values --> Value
//! ```
//!
//!
//! # Http Request Chaining (gearbox::net::http::request_chaining)
//!
//! ## Complete architectural overview:
//! ```mermaid
//! classDiagram
//! %% Package: request
//! namespace request {
//! class Client {
//! +client: reqwest::Client
//! +new()
//! +with_client(reqwest::Client)
//! +set_global_signing(Signature)
//! }
//!
//! class Error {
//! +UrlParser(ParseError)
//! +Request(reqwest::Error)
//! +NoUrl
//! +HeaderValue(reqwest::header::InvalidHeaderValue)
//! +DeserializeContentType(String)
//! +DeserializeJson(serde_json::Error)
//! +BodyError(TracerError)
//! }
//!
//! class Method {
//! <<enumeration>>
//! Get
//! Post
//! Put
//! Delete
//! Patch
//! Head
//! Options
//! Connect
//! Trace
//! None
//! }
//!
//! class RequestBuilder {
//! +client: Option<Arc<Client>>
//! +method: Method
//! +uri: Option<Url>
//! +headers: HeaderMap
//! +body: Body
//! +content_type: String
//! +signature: Option<Signature>
//! +new_with_client(client: Option<Client>, method: Method, uri: Url)
//! +method(T: Into<Method>)
//! +uri(uri: &str)
//! +header(H: Into<Header>)
//! +headers(H: Into<HeaderMap>)
//! +body(B: Into<Body>)
//! +content_type(content_type: &str)
//! +with_signing_default()
//! +with_signing(signature: Signature)
//! +send()
//! }
//!
//! class Response {
//! +status: StatusCode
//! +headers: HeaderMap
//! +content_length: Option<u64>
//! +url: Url
//! +body: BodyOwned
//! +status()
//! +to(T: DeserializeOwned)
//! }
//!
//! class StatusCode {
//! +code: u16
//! +reason: &'static str
//! +as_u16()
//! +as_str()
//! }
//!
//! class Url {
//! +Simple(url: String)
//! }
//!
//! class Body {
//! +Empty
//! }
//!
//! class BodyOwned {
//! +from(box_raw: Box<reqwest::Response>)
//! }
//! }
//!
//! %% Package: request_chaining
//! namespace request_chaining {
//! class Header {
//! +name: Name
//! +values: Values
//! }
//!
//! class HeaderMap {
//! +inner: HashMap<Name, Values>
//! +get(K: Into<Name>)
//! +insert(header: Header)
//! +extend(headers: HeaderMap)
//! }
//!
//! class Name {
//! +String name
//! }
//!
//! class Values {
//! +Vec<Value> values
//! +iter()
//! }
//!
//! class Value {
//! +Vec<u8> value
//! +as_bytes()
//! +to_vec()
//! }
//!
//! class TracerError
//! class Signature
//! class ParseError
//! }
//!
//! %% Relationships
//! Client --> RequestBuilder
//! RequestBuilder --> Response
//! RequestBuilder --> Error
//! Response --> StatusCode
//! Response --> HeaderMap
//! Response --> Url
//! Response --> BodyOwned
//! HeaderMap --> Header
//! Header --> Name
//! Header --> Values
//! Values --> Value
//! ```
//!
//! # Signature (gearbox::net::signature)
//! ([docs: gearbox::net::signature](./src/net/signature/mod.rs))
//!
//!
//! # Railway Future extension (gearbox::rails::ext::future)
//! ([docs: gearbox::serde::dynamic](./src/rails/ext/future/mod.rs))
//!
//! # Dynamic Serialization/Deserialization (gearbox::serde::dynamic)
//! ([docs: gearbox::serde::dynamic](./src/serde/dynamic/mod.rs))
//!
//! # RwArc (gearbox::sync::rw_arc)
//! ([docs: gearbox::sync::rw_arc](./src/sync/rw_arc/mod.rs))
//!
//! # RwArc (gearbox::template)
//! ([docs: gearbox::template](./src/template/mod.rs))
//!
//! ## TODO
//!
//! - [ ] ( gearbox::log::* ) Clean up Log fmt/syslog, some of the code can be combined and cleaned up a bit better, also the formatter supports syslog, and bunyan, this should probably be cleared up a bit more, and separated better.
//! - [ ] ( gearbox::path::* ) current this system is mainly just exposing the dirs::* library, this should be removed.
//! - [ ] ( gearbox::* ) Remove usage for Vec or move usage of std::vec::Vec to another no-std library
//!
//!
//!
compile_error!;
pub extern crate alloc;
pub extern crate base64;
pub extern crate bs58;
pub extern crate bson;
pub extern crate bytes;
pub extern crate core;
pub extern crate didkit;
pub extern crate erased_serde;
pub extern crate flexbuffers;
pub extern crate futures;
pub extern crate hashbrown;
pub extern crate hex;
pub extern crate hmac;
pub extern crate json5;
pub extern crate postcard;
pub extern crate reqwest;
pub extern crate rmp_serde;
pub extern crate ron;
pub extern crate semver;
pub extern crate serde as crate_serde;
pub extern crate serde_cbor;
pub extern crate serde_derive;
pub extern crate serde_json;
pub extern crate serde_lexpr;
pub extern crate serde_pickle as pickle;
pub extern crate serde_qs;
pub extern crate serde_xml_rs;
pub extern crate serde_yaml;
pub extern crate sha2;
pub extern crate spin;
pub extern crate std;
pub extern crate tokio;
pub extern crate tracing;
pub extern crate uniffi;
pub extern crate uniffi_macros;
pub extern crate web_sys;
pub extern crate derive_more;
pub extern crate gearbox_macros;
// ## For Testing!
pub extern crate hyper;
pub extern crate wasm_bindgen_test;
// uniffi::setup_scaffolding!();
pub use crate*;
pub use crate*;
pub use crate*;