Skip to content

Commit

Permalink
Merge pull request #58 from phip1611/clippy
Browse files Browse the repository at this point in the history
clippy: add clippy::must_use_candidate
  • Loading branch information
phip1611 authored Jul 10, 2024
2 parents e5efdf5 + 1447997 commit a4b9d3a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
10 changes: 5 additions & 5 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
rustup
];
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
rustup
];
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ SOFTWARE.
clippy::all,
clippy::cargo,
clippy::nursery,
clippy::must_use_candidate,
// clippy::restriction,
// clippy::pedantic
)]
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SOFTWARE.
clippy::all,
clippy::cargo,
clippy::nursery,
clippy::must_use_candidate,
// clippy::restriction,
// clippy::pedantic
)]
Expand Down
10 changes: 10 additions & 0 deletions src/outcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ impl DurationPair {
}

/// Returns the duration of that step.
#[must_use]
pub const fn relative(&self) -> Duration {
self.rel
}

/// Returns the total duration between the start of the measurement
/// and the end of this measurement step.
#[must_use]
pub const fn total(&self) -> Duration {
self.total
}
Expand Down Expand Up @@ -104,33 +106,39 @@ impl TtfbOutcome {
}

/// Getter for the provided user input (Host or IP address).
#[must_use]
pub fn user_input(&self) -> &str {
&self.user_input
}

/// Getter for `ip_addr` that was used.
#[must_use]
pub const fn ip_addr(&self) -> IpAddr {
self.ip_addr
}

/// Getter for `port` that was used.
#[must_use]
pub const fn port(&self) -> u16 {
self.port
}

/// Returns the [`DurationPair`] for the DNS step, if DNS lookup was necessary.
#[must_use]
pub fn dns_lookup_duration(&self) -> Option<DurationPair> {
self.dns_duration_rel
.map(|d| DurationPair::new(d, Duration::default()))
}

/// Returns the [`DurationPair`] for the establishment of the TCP connection.
#[must_use]
pub fn tcp_connect_duration(&self) -> DurationPair {
let abs_dur_so_far = self.dns_lookup_duration().unwrap_or_default().total();
DurationPair::new(self.tcp_connect_duration_rel, abs_dur_so_far)
}

/// Returns the [`DurationPair`] for the TLS handshake, if the TLS handshake was necessary.
#[must_use]
pub fn tls_handshake_duration(&self) -> Option<DurationPair> {
self.tls_handshake_duration_rel.map(|dur| {
let abs_dur_so_far = self.tcp_connect_duration().total();
Expand All @@ -139,12 +147,14 @@ impl TtfbOutcome {
}

/// Returns the [`DurationPair`] for the transmission of the HTTP GET request.
#[must_use]
pub fn http_get_send_duration(&self) -> DurationPair {
let abs_dur_so_far = self.tls_handshake_duration().unwrap_or_default().total();
DurationPair::new(self.http_get_send_duration_rel, abs_dur_so_far)
}

/// Returns the [`DurationPair`] for the time to first byte (TTFB) of the HTTP response.
#[must_use]
pub fn ttfb_duration(&self) -> DurationPair {
let abs_dur_so_far = self.http_get_send_duration().total();
DurationPair::new(self.http_ttfb_duration_rel, abs_dur_so_far)
Expand Down

0 comments on commit a4b9d3a

Please sign in to comment.