utils_box_connections/
lib.rs

1//! # Summary
2//! A toolbox library that holds a useful collection of small unitilies written in Rust that make our life easier when writting Rust applications.
3//!
4//! # Utilities provided:
5//!
6//! ## SSH Client
7//! Connect via SSH to a server to perform commands, upload & download files
8//!
9//! Mininal Example:
10//! ```ignore
11//!     let ssh = SshClient::local("user".to_string(), "1234".to_string()).unwrap();
12//!
13//!     let stdout = ssh.execute_cmd("ls").unwrap();
14//!
15//!     println!("{:?}", stdout);
16//!
17//! ```
18//!
19//! ## TCP Client
20//! Connect via TCP to a socket to send and receive data
21//!
22//! Mininal Example:
23//! ```ignore
24//!     let mut tcp_client = TcpClient::new("192.168.1.17".to_string(), 36457)?;
25//!
26//!     let data: Vec<u8> = vec![8, 30, 15, 30, 5, 19, 0, 7];
27//!
28//!     tcp_client.send(&data)?;
29//!
30//!     // Block and wait for response
31//!     let resp = tcp_client.receive()?;
32//!
33//!      println!("{:?}", resp);
34//!
35//! ```
36//!
37//! ## TCP Client
38//! Connect via UDP to a socket to send and receive data
39//!
40//! Mininal Example:
41//! ```ignore
42//!      let mut udp =
43//!             UdpClient::new("0.0.0.0".to_string(), "192.168.1.31".to_string(), 6123).unwrap();
44//!
45//!     udp.send(b"\r").unwrap();
46//!
47//!     // Block and wait for response
48//!     let data = udp.receive().unwrap();
49//!
50//!     println!("{:?} => {}", data, String::from_utf8_lossy(&data));
51//!
52//! ```
53//!
54//! ## ZMQ Client
55//! Connect to a ZMQ server to send and receive data
56//!
57//! Mininal Example:
58//! ```ignore
59//!     let zmq_client = ZmqClient::new(("192.168.1.17".to_string(), 36457)?;
60//!
61//!     let data: Vec<u8> = vec![8, 30, 15, 30, 5, 19, 0, 7];
62//!
63//!     zmq_client.send(&data)?;
64//!
65//!     // Block and wait for response
66//!     let resp = zmq_client.receive()?;
67//!
68//!     println!("{:?}", resp);
69//!
70//! ```
71//!
72
73#[cfg(feature = "ssh")]
74pub mod ssh_client;
75#[cfg(feature = "tcp")]
76pub mod tcp_client;
77#[cfg(feature = "udp")]
78pub mod udp_client;
79#[cfg(feature = "zmq")]
80pub mod zmq_client;