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
//! # Summary
//! A toolbox library that holds a useful collection of small unitilies written in Rust that make our life easier when writting Rust applications.
//!
//! # Utilities provided:
//!
//! ## Mathematics
//! A collection of useful methematic methods used in various DSP and other applications
//!
//! ## Archives
//! Extract files from Tar, Gz and Zip Files
//!
//! Mininal Example:
//! ```ignore
//! let archive: PathBuf = std::env::current_exe()
//!     .unwrap()
//!     .parent()
//!     .unwrap()
//!     .join("test_archive.tar.gz");
//!
//! let file: PathBuf = "treasure.hex".into();
//!
//! let destination: PathBuf = std::env::current_exe()
//!     .unwrap()
//!     .parent()
//!     .unwrap();
//!
//! archives::extract_file(archive, ArchiveType::Gz, file, destination).unwrap();
//!
//! ```
//!
//! ## Bits
//! Convertions between different representations of raw bit streams
//!
//! Mininal Example:
//! ```ignore
//! let received_bit_stream: u64 = 0b110101000100111010110;
//!
//! let bytes = bits::bits_to_vec(received_bit_stream,21);
//!
//! println!("Received bit stream: {} ", bits::bit_vec_to_hex_string(&bytes));
//!
//! ```
//!
//! ## Config
//! Manipulate INI-style configuration files by checking for changes, updates etc
//!
//! Mininal Example:
//! ```ignore
//!     let mut config_changes = ini_compare(
//!         &old_config_path.to_path_buf(),
//!         &new_config_path.to_path_buf(),
//!     )
//!     .unwrap();
//!
//!    println!("{:#?}", config_changes);
//!
//! ```
//!
//! ## Logger
//! Initialize terminal and file loggers fast. Macros for log printing to either log or stdout (if a global logger is not initialized)
//!
//! Mininal Example:
//! ```ignore
//!     log_info!("INFO Test TO PRINTLN!");
//!     log_debug!("DEBUG Test TO PRINTLN!");
//!
//!     terminal_logger_init(LevelFilter::Debug);
//!
//!     log_info!("INFO Test TO LOGGER!");
//!     log_debug!("DEBUG Test TO LOGGER!");
//!
//! ```
//!
//! ## Paths
//! Search paths for a specific file in directories with known or unknown paths
//!
//! Mininal Example:
//! ```ignore
//!     let paths = IncludePathsBuilder::new()
//!             .include_exe_dir()
//!             .include_known("/home/user/")
//!             .include_unknown("utils-box")
//!             .build();
//!
//!     let pattern = "test_*.tar";
//!
//!     let file_found_in = paths.search_glob(pattern);
//!
//! ```
//!
//! ## Stopwatch and Timekeper
//! Keep track of execution times in various points in binaries. Print records.
//!
//! Minimal Example:
//! ```ignore
//!    let mut s = TimeKeeper::init();
//!    let mut t = TimeKeeper::init();
//!
//!    s.totals();
//!
//!    s.lap("init");
//!
//!    for _ in 0..5 {
//!        std::thread::sleep(Duration::from_millis(5));
//!        s.lap("loop");
//!        t.lap("loop");
//!    }
//!    s.lap_totals("loop");
//!    std::thread::sleep(Duration::from_millis(1234));
//!    s.lap("after");
//!
//!    s.totals();
//!    t.totals();
//!
//!    s.merge(t);
//!
//!    s.totals();
//!
//! ```
//!
//! ## Versions
//! version parser from strings using the `semver.org` notations
//!
//! Mininal Example:
//! ```ignore
//!    let version = "0.9.2-1e341234";
//!
//!     let mut expected = Version::new(0, 9, 2);
//!     expected.pre = Prerelease::new("1e341234").unwrap();
//!
//!     assert_eq!(semver_parse(version).unwrap(), expected);
//!
//! ```
//!
//! ## SSH Client
//! Connect via SSH to a server to perform commands, upload & download files
//!
//! Mininal Example:
//! ```ignore
//!     let ssh = SshClient::local("user".to_string(), "1234".to_string()).unwrap();
//!
//!     let stdout = ssh.execute_cmd("ls").unwrap();
//!
//!     println!("{:?}", stdout);
//!
//! ```
//!
//! ## TCP Client
//! Connect via TCP to a socket to send and receive data
//!
//! Mininal Example:
//! ```ignore
//!     let mut tcp_client = TcpClient::new("192.168.1.17".to_string(), 36457)?;
//!
//!     let data: Vec<u8> = vec![8, 30, 15, 30, 5, 19, 0, 7];
//!
//!     tcp_client.send(&data)?;
//!
//!     // Block and wait for response
//!     let resp = tcp_client.receive()?;
//!
//!      println!("{:?}", resp);
//!
//! ```
//!
//! ## TCP Client
//! Connect via UDP to a socket to send and receive data
//!
//! Mininal Example:
//! ```ignore
//!      let mut udp =
//!             UdpClient::new("0.0.0.0".to_string(), "192.168.1.31".to_string(), 6123).unwrap();
//!
//!     udp.send(b"\r").unwrap();
//!
//!     // Block and wait for response
//!     let data = udp.receive().unwrap();
//!
//!     println!("{:?} => {}", data, String::from_utf8_lossy(&data));
//!
//! ```
//!
//! ## ZMQ Client
//! Connect to a ZMQ server to send and receive data
//!
//! Mininal Example:
//! ```ignore
//!     let zmq_client = ZmqClient::new(("192.168.1.17".to_string(), 36457)?;
//!
//!     let data: Vec<u8> = vec![8, 30, 15, 30, 5, 19, 0, 7];
//!
//!     zmq_client.send(&data)?;
//!
//!     // Block and wait for response
//!     let resp = zmq_client.receive()?;
//!
//!     println!("{:?}", resp);
//!
//! ```
//!

pub mod archives;
pub mod bits;
pub mod config;
#[cfg(not(tarpaulin_include))]
pub mod debug;
pub mod paths;
pub mod versions;

#[cfg(not(tarpaulin_include))]
#[cfg(target_family = "unix")]
pub mod connections;

#[macro_use]
pub mod logger;
pub mod stopwatch;

#[cfg(target_family = "unix")]
#[cfg(not(tarpaulin_include))]
pub mod threads;

pub mod mathematics;