Skip to content

Commit

Permalink
Fix Rust 1.79 warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcamiel committed Jun 14, 2024
1 parent d13d4ea commit d51c275
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
5 changes: 0 additions & 5 deletions packages/hurl/src/http/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
use std::time::Duration;

use hurl_core::ast::Retry;

use crate::http::request::RequestedHttpVersion;
use crate::http::IpResolve;

Expand Down Expand Up @@ -46,7 +44,6 @@ pub struct ClientOptions {
pub path_as_is: bool,
pub proxy: Option<String>,
pub resolves: Vec<String>,
pub retry: Retry,
pub ssl_no_revoke: bool,
pub timeout: Duration,
pub unix_socket: Option<String>,
Expand Down Expand Up @@ -87,7 +84,6 @@ impl Default for ClientOptions {
path_as_is: false,
proxy: None,
resolves: vec![],
retry: Retry::None,
ssl_no_revoke: false,
timeout: Duration::from_secs(300),
unix_socket: None,
Expand Down Expand Up @@ -242,7 +238,6 @@ mod tests {
"foo.com:80:192.168.0.1".to_string(),
"bar.com:443:127.0.0.1".to_string(),
],
retry: Retry::None,
ssl_no_revoke: false,
timeout: Duration::from_secs(10),
unix_socket: Some("/var/run/example.sock".to_string()),
Expand Down
10 changes: 5 additions & 5 deletions packages/hurl/src/parallel/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::io;

use crate::parallel::job::{Job, JobResult};
use crate::parallel::worker::WorkerId;
use crate::util::term::{Stderr, Stdout};
use crate::util::term::Stderr;

/// Represents a message sent from the worker to the runner (running on the main thread).
pub enum WorkerMessage {
Expand All @@ -38,6 +38,7 @@ pub enum WorkerMessage {
/// A message sent from worker to runner when the input file can't be read.
pub struct IOErrorMsg {
/// Identifier of the worker sending this message.
#[allow(dead_code)]
pub worker_id: WorkerId,
/// Job originator of this message.
pub job: Job,
Expand All @@ -59,8 +60,10 @@ impl IOErrorMsg {
/// A message sent from worker to runner when the input file can't be parsed.
pub struct ParsingErrorMsg {
/// Identifier of the worker sending this message.
#[allow(dead_code)]
pub worker_id: WorkerId,
/// Job originator of this message.
#[allow(dead_code)]
pub job: Job,
/// Standard error of the worker for this job.
pub stderr: Stderr,
Expand Down Expand Up @@ -107,19 +110,16 @@ pub struct CompletedMsg {
pub worker_id: WorkerId,
/// Result execution of the originator job, can successful or failed.
pub result: JobResult,
/// Standard output of the worker for this job.
pub stdout: Stdout,
/// Standard error of the worker for this job.
pub stderr: Stderr,
}

impl CompletedMsg {
/// Creates a new completed message: the job has completed, successfully or not.
pub fn new(worker_id: WorkerId, result: JobResult, stdout: Stdout, stderr: Stderr) -> Self {
pub fn new(worker_id: WorkerId, result: JobResult, stderr: Stderr) -> Self {
CompletedMsg {
worker_id,
result,
stdout,
stderr,
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/hurl/src/parallel/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl Worker {
));
}
let job_result = JobResult::new(job, content, result);
let msg = CompletedMsg::new(worker_id, job_result, stdout, logger.stderr);
let msg = CompletedMsg::new(worker_id, job_result, logger.stderr);
_ = tx.send(WorkerMessage::Completed(msg));
});

Expand Down
15 changes: 13 additions & 2 deletions packages/hurl/src/report/junit/xml/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*
*/
use std::borrow::Cow;
use std::fmt;
use std::fmt::{Debug, Formatter};
use std::string::FromUtf8Error;

use xml::attribute::Attribute;
Expand All @@ -24,7 +26,6 @@ use xml::namespace::Namespace;
use xml::writer::{Error, XmlEvent};
use xml::EventWriter;

use crate::report::junit::xml::writer::WriterError::GenericError;
use crate::report::junit::xml::{Element, XmlDocument, XmlNode};

/// Errors raised when serializing an XML document.
Expand All @@ -35,14 +36,24 @@ pub enum WriterError {
GenericError(String),
}

impl fmt::Display for WriterError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
WriterError::Io(err) => write!(f, "{err}"),
WriterError::FromUtf8Error(err) => write!(f, "{err}"),
WriterError::GenericError(err) => write!(f, "{err}"),
}
}
}

impl From<Error> for WriterError {
fn from(value: Error) -> Self {
match value {
Error::Io(error) => WriterError::Io(error),
Error::DocumentStartAlreadyEmitted
| Error::LastElementNameNotAvailable
| Error::EndElementNameIsNotEqualToLastStartElementName
| Error::EndElementNameIsNotSpecified => GenericError(value.to_string()),
| Error::EndElementNameIsNotSpecified => WriterError::GenericError(value.to_string()),
}
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/hurl/src/runner/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ impl ClientOptions {
no_proxy: runner_options.no_proxy.clone(),
insecure: runner_options.insecure,
resolves: runner_options.resolves.clone(),
retry: runner_options.retry,
ssl_no_revoke: runner_options.ssl_no_revoke,
timeout: runner_options.timeout,
unix_socket: runner_options.unix_socket.clone(),
Expand Down

0 comments on commit d51c275

Please sign in to comment.