Skip to content

Commit a5b50d9

Browse files
committed
doc: correct documentation issues
- fix some failing doc-tests. - amend formatting causing misinterpretation as code-samples. - mark some examples as [`compile_fail`](https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#attributes) as there's no immediate way to instantiate the required `struct`.
1 parent 2716747 commit a5b50d9

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

src/benchmark/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
//! # Usage
2-
//! ```
2+
//!
3+
//! ```rust
34
//! // Initiate Benchmark vector
5+
//! # use rustscan::benchmark::{Benchmark, NamedTimer};
6+
//! # use log::info;
47
//! let mut bm = Benchmark::init();
58
//! // Start named timer with name
69
//! let mut example_bench = NamedTimer::start("Example Bench");
710
//! // Stop named timer
8-
//! example_bench.stop();
11+
//! example_bench.end();
912
//! // Add named timer to Benchmarks
1013
//! bm.push(example_bench);
1114
//! // Print Benchmark Summary
12-
//! info!({}, bm.summary());
15+
//! info!("{}", bm.summary());
1316
//! ```
1417
use std::time::Instant;
1518

src/scanner/mod.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Scanner {
6464

6565
/// Runs scan_range with chunk sizes
6666
/// If you want to run RustScan normally, this is the entry point used
67-
/// Returns all open ports as Vec<u16>
67+
/// Returns all open ports as `Vec<u16>`
6868
/// Added by wasuaje - 01/26/2024:
6969
/// Filtering port against exclude port list
7070
pub async fn run(&self) -> Vec<SocketAddr> {
@@ -116,14 +116,16 @@ impl Scanner {
116116

117117
/// Given a socket, scan it self.tries times.
118118
/// Turns the address into a SocketAddr
119-
/// Deals with the <result> type
119+
/// Deals with the `<result>` type
120120
/// If it experiences error ErrorKind::Other then too many files are open and it Panics!
121121
/// Else any other error, it returns the error in Result as a string
122122
/// If no errors occur, it returns the port number in Result to signify the port is open.
123123
/// This function mainly deals with the logic of Results handling.
124124
/// # Example
125125
///
126-
/// self.scan_socket(socket)
126+
/// ```compile_fail
127+
/// scanner.scan_socket(socket)
128+
/// ```
127129
///
128130
/// Note: `self` must contain `self.ip`.
129131
async fn scan_socket(&self, socket: SocketAddr) -> io::Result<SocketAddr> {
@@ -169,13 +171,16 @@ impl Scanner {
169171
/// Performs the connection to the socket with timeout
170172
/// # Example
171173
///
172-
/// let port: u16 = 80
173-
/// // ip is an IpAddr type
174-
/// let ip = IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
175-
/// let socket = SocketAddr::new(ip, port);
176-
/// self.connect(socket)
177-
/// // returns Result which is either Ok(stream) for port is open, or Er for port is closed.
178-
/// // Timeout occurs after self.timeout seconds
174+
/// ```compile_fail
175+
/// # use std::net::{IpAddr, Ipv6Addr, SocketAddr};
176+
/// let port: u16 = 80;
177+
/// // ip is an IpAddr type
178+
/// let ip = IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
179+
/// let socket = SocketAddr::new(ip, port);
180+
/// scanner.connect(socket);
181+
/// // returns Result which is either Ok(stream) for port is open, or Er for port is closed.
182+
/// // Timeout occurs after self.timeout seconds
183+
/// ```
179184
///
180185
async fn connect(&self, socket: SocketAddr) -> io::Result<TcpStream> {
181186
let stream = io::timeout(

src/scripts/mod.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
//!
66
//! --scripts
77
//!
8-
//! default
9-
//! This is the default behavior, like as it was from the beginning of RustScan.
10-
//! The user do not have to chose anything for this. This is the only script embedded in RustScan running as default.
8+
//! default
9+
//! This is the default behavior, like as it was from the beginning of RustScan.
10+
//! The user do not have to chose anything for this. This is the only script embedded in RustScan running as default.
1111
//!
12-
//! none
13-
//! The user have to use the --scripts none commandline argument or scripts = "none" in the config file.
14-
//! None of the scripts will run, this replaces the removed --no-nmap option.
12+
//! none
13+
//! The user have to use the --scripts none commandline argument or scripts = "none" in the config file.
14+
//! None of the scripts will run, this replaces the removed --no-nmap option.
1515
//!
16-
//! custom
17-
//! The user have to use the --scripts custom commandline argument or scripts = "custom" in the config file.
18-
//! Rustscan will look for the script configuration file in the user's home dir: home_dir/.rustscan_scripts.toml
19-
//! The config file have 3 optional fields, tag, developer and port. Just the tag field will be used forther in the process.
20-
//! RustScan will also look for available scripts in the user's home dir: home_dir/.rustscan_scripts
21-
//! and will try to read all the files, and parse them into a vector of ScriptFiles.
22-
//! Filtering on tags means the tags found in the rustscan_scripts.toml file will also have to be present in the Scriptfile,
23-
//! otherwise the script will not be selected.
24-
//! All of the rustscan_script.toml tags have to be present at minimum in a Scriptfile to get selected, but can be also more.
16+
//! custom
17+
//! The user have to use the --scripts custom commandline argument or scripts = "custom" in the config file.
18+
//! Rustscan will look for the script configuration file in the user's home dir: home_dir/.rustscan_scripts.toml
19+
//! The config file have 3 optional fields, tag, developer and port. Just the tag field will be used forther in the process.
20+
//! RustScan will also look for available scripts in the user's home dir: home_dir/.rustscan_scripts
21+
//! and will try to read all the files, and parse them into a vector of ScriptFiles.
22+
//! Filtering on tags means the tags found in the rustscan_scripts.toml file will also have to be present in the Scriptfile,
23+
//! otherwise the script will not be selected.
24+
//! All of the rustscan_script.toml tags have to be present at minimum in a Scriptfile to get selected, but can be also more.
2525
//!
2626
//! Config file example:
2727
//! fixtures/test_rustscan_scripts.toml

0 commit comments

Comments
 (0)