diff --git a/Cargo.toml b/Cargo.toml index 5fd7bd7f..814eb045 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,13 +21,10 @@ reqwest = "0.9" serde = { version = "1.0", features = [ "derive" ] } serde_json = "1.0" serde_urlencoded = "0.6" - urlencoding = "1.0.0" - -failure = "0.1" -regex = "1.1" - +regex = "1.3" log = "0.4" +thiserror = "1.0" [build-dependencies] skeptic = "0.13" diff --git a/src/action/maven.rs b/src/action/maven.rs index 62c63971..0046e526 100644 --- a/src/action/maven.rs +++ b/src/action/maven.rs @@ -1,9 +1,8 @@ //! Types related to maven -use failure::Error; use serde::Deserialize; -use crate::client; +use crate::client::{self, Result}; use crate::client_internals::path::Path; use crate::Jenkins; @@ -42,7 +41,7 @@ impl ShortMavenArtifactRecord { pub fn get_full_artifact_record( &self, jenkins_client: &Jenkins, - ) -> Result { + ) -> Result { let path = jenkins_client.url_to_path(&self.url); if let Path::MavenArtifactRecord { .. } = path { Ok(jenkins_client.get(&path)?.json()?) diff --git a/src/build/common.rs b/src/build/common.rs index f295646f..b1a078fa 100644 --- a/src/build/common.rs +++ b/src/build/common.rs @@ -1,13 +1,12 @@ use std::marker::PhantomData; -use failure::Error; use serde::{self, Deserialize, Serialize}; use serde_json; use crate::helpers::Class; use crate::action::CommonAction; -use crate::client; +use crate::client::{self, Result}; use crate::client_internals::path::Path; use crate::job::{CommonJob, Job}; use crate::Jenkins; @@ -36,7 +35,7 @@ where for<'de> T: Deserialize<'de>, { /// Get the full details of a `Build` matching the `ShortBuild` - pub fn get_full_build(&self, jenkins_client: &Jenkins) -> Result { + pub fn get_full_build(&self, jenkins_client: &Jenkins) -> Result { let path = jenkins_client.url_to_path(&self.url); if let Path::Build { .. } = path { Ok(jenkins_client.get(&path)?.json()?) @@ -165,7 +164,7 @@ pub trait Build { fn url(&self) -> &str; /// Get the `Job` from a `Build` - fn get_job(&self, jenkins_client: &Jenkins) -> Result + fn get_job(&self, jenkins_client: &Jenkins) -> Result where for<'de> Self::ParentJob: Deserialize<'de>, { @@ -192,7 +191,7 @@ pub trait Build { } /// Get the console output from a `Build` - fn get_console(&self, jenkins_client: &Jenkins) -> Result { + fn get_console(&self, jenkins_client: &Jenkins) -> Result { let path = jenkins_client.url_to_path(&self.url()); if let Path::Build { job_name, diff --git a/src/build/mod.rs b/src/build/mod.rs index 76508ef8..9b6db4b5 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -1,7 +1,6 @@ //! Jenkins Builds -use failure::Error; - +use crate::client::Result; use crate::client_internals::path::{Name, Path}; use crate::job::JobName; use crate::Jenkins; @@ -24,7 +23,7 @@ pub use self::multijob::MultiJobBuild; impl Jenkins { /// Get a build from a `job_name` and `build_number` - pub fn get_build<'a, J, B>(&self, job_name: J, build_number: B) -> Result + pub fn get_build<'a, J, B>(&self, job_name: J, build_number: B) -> Result where J: Into>, B: Into, diff --git a/src/client.rs b/src/client.rs index 15b8f77a..128bc28d 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,6 +1,5 @@ //! Helpers to build advanced queries -use failure::Error as FailureError; use serde::{self, Deserialize}; use crate::client_internals::path::{Name, Path as PrivatePath}; @@ -8,7 +7,7 @@ use crate::client_internals::InternalAdvancedQueryParams; // pub use client_internals::path::Name; pub use crate::client_internals::AdvancedQuery; -pub use crate::client_internals::{error, Error}; +pub use crate::client_internals::{error, Error, Result}; pub use crate::client_internals::{TreeBuilder, TreeQueryParam}; use crate::build; @@ -118,7 +117,6 @@ impl super::Jenkins { /// # Example /// /// ```rust - /// # extern crate failure; /// # #[macro_use] /// # extern crate serde; /// # @@ -140,7 +138,7 @@ impl super::Jenkins { /// last_build: LastBuild, /// } /// - /// # fn main() -> Result<(), failure::Error> { + /// # fn main() -> Result<(), Box> { /// # let jenkins = JenkinsBuilder::new("http://localhost:8080") /// # .with_user("user", Some("password")) /// # .build()?; @@ -163,7 +161,7 @@ impl super::Jenkins { /// # } /// ``` /// - pub fn get_object_as(&self, object: Path, parameters: Q) -> Result + pub fn get_object_as(&self, object: Path, parameters: Q) -> Result where Q: Into>, for<'de> T: Deserialize<'de>, diff --git a/src/client_internals/builder.rs b/src/client_internals/builder.rs index c78a43b3..2cf51c19 100644 --- a/src/client_internals/builder.rs +++ b/src/client_internals/builder.rs @@ -1,9 +1,9 @@ use std::str::FromStr; -use failure::Error; use reqwest::{self, Client, Url}; use super::{Jenkins, User}; +use crate::client::Result; /// Builder for Jenkins client /// @@ -45,7 +45,7 @@ impl JenkinsBuilder { } /// Build the Jenkins client - pub fn build(self) -> Result { + pub fn build(self) -> Result { let url = Url::from_str(&self.url)?; if url.cannot_be_a_base() { return Err(reqwest::UrlError::RelativeUrlWithoutBase.into()); diff --git a/src/client_internals/csrf.rs b/src/client_internals/csrf.rs index b1dee8eb..ed04bef1 100644 --- a/src/client_internals/csrf.rs +++ b/src/client_internals/csrf.rs @@ -1,9 +1,8 @@ -use failure; - use reqwest::{header::HeaderName, header::HeaderValue, RequestBuilder}; use serde::Deserialize; use super::{path::Path, Jenkins}; +use crate::client::Result; #[derive(Debug, Deserialize, Clone)] #[serde(rename_all = "camelCase")] @@ -16,7 +15,7 @@ impl Jenkins { pub(crate) fn add_csrf_to_request( &self, request_builder: RequestBuilder, - ) -> Result { + ) -> Result { if self.csrf_enabled { let crumb = self.get_csrf()?; Ok(request_builder.header( @@ -28,7 +27,7 @@ impl Jenkins { } } - pub(crate) fn get_csrf(&self) -> Result { + pub(crate) fn get_csrf(&self) -> Result { let crumb: Crumb = self.get(&Path::CrumbIssuer)?.json()?; Ok(crumb) } diff --git a/src/client_internals/errors.rs b/src/client_internals/errors.rs index 19d71e78..fd4af709 100644 --- a/src/client_internals/errors.rs +++ b/src/client_internals/errors.rs @@ -1,12 +1,15 @@ use std::fmt; -use failure::Fail; +use thiserror::Error; + +/// Wrapper `Result` type +pub type Result = std::result::Result>; /// Errors that can be thrown -#[derive(Debug, Fail)] +#[derive(Debug, Error)] pub enum Error { - /// Error thrown when a link between objects has an unexpected format - #[fail(display = "invalid url for {}: {}", expected, url)] + #[error("invalid url for {expected}: {url}")] + /// Error thrown when a link between objects has an unexpected format InvalidUrl { /// URL found url: String, @@ -14,38 +17,33 @@ pub enum Error { expected: ExpectedType, }, - /// Error thrown when CSRF protection use an unexpected field name - #[fail( - display = "invalid crumbfield '{}', expected 'Jenkins-Crumb'", - field_name - )] + #[error("invalid crumbfield '{field_name}', expected 'Jenkins-Crumb'")] + /// Error thrown when CSRF protection use an unexpected field name InvalidCrumbFieldName { /// Field name provided by Jenkins api for crumb field_name: String, }, - /// Error thrown when building a parameterized job with an invalid parameter - #[fail(display = "illegal argument: '{}'", message)] + #[error("illegal argument: '{message}'")] + /// Error thrown when building a parameterized job with an invalid parameter IllegalArgument { /// Exception message provided by Jenkins message: String, }, - /// Error thrown when building a job with invalid parameters - #[fail(display = "illegal state: '{}'", message)] + + #[error("illegal state: '{message}'")] + /// Error thrown when building a job with invalid parameters IllegalState { /// Exception message provided by Jenkins message: String, }, - /// Error when trying to remotely build a job with parameters - #[fail(display = "can't build a job remotely with parameters")] + #[error("can't build a job remotely with parameters")] + /// Error when trying to remotely build a job with parameters UnsupportedBuildConfiguration, - /// Error when trying to do an action on an object not supporting it - #[fail( - display = "can't do '{}' on a {} of type {}", - action, object_type, variant_name - )] + #[error("can't do '{action}' on a {object_type} of type {variant_name}")] + /// Error when trying to do an action on an object not supporting it InvalidObjectType { /// Object type object_type: ExpectedType, diff --git a/src/client_internals/mod.rs b/src/client_internals/mod.rs index 23639105..ceb367f8 100644 --- a/src/client_internals/mod.rs +++ b/src/client_internals/mod.rs @@ -3,7 +3,6 @@ use std::fmt::Debug; use std::string::ToString; -use failure; use log::{debug, warn}; use regex::Regex; use reqwest::{ @@ -12,7 +11,7 @@ use reqwest::{ use serde::Serialize; mod errors; -pub use self::errors::Error; +pub use self::errors::{Error, Result}; mod builder; pub mod path; pub use self::builder::JenkinsBuilder; @@ -84,7 +83,7 @@ impl Jenkins { format!("{}{}", self.url, endpoint) } - fn send(&self, mut request_builder: RequestBuilder) -> Result { + fn send(&self, mut request_builder: RequestBuilder) -> Result { if let Some(ref user) = self.user { request_builder = request_builder.basic_auth(user.username.clone(), user.password.clone()); @@ -94,7 +93,7 @@ impl Jenkins { Ok(self.client.execute(query)?) } - fn error_for_status(response: Response) -> Result { + fn error_for_status(response: Response) -> Result { let status = response.status(); if status.is_client_error() || status.is_server_error() { warn!("got an error: {}", status); @@ -102,15 +101,11 @@ impl Jenkins { Ok(response.error_for_status()?) } - pub(crate) fn get(&self, path: &Path) -> Result { + pub(crate) fn get(&self, path: &Path) -> Result { self.get_with_params(path, &[("depth", &self.depth.to_string())]) } - pub(crate) fn get_with_params( - &self, - path: &Path, - qps: T, - ) -> Result { + pub(crate) fn get_with_params(&self, path: &Path, qps: T) -> Result { let query = self .client .get(&self.url_api_json(&path.to_string())) @@ -118,7 +113,7 @@ impl Jenkins { Ok(Self::error_for_status(self.send(query)?)?) } - pub(crate) fn post(&self, path: &Path) -> Result { + pub(crate) fn post(&self, path: &Path) -> Result { let mut request_builder = self.client.post(&self.url(&path.to_string())); request_builder = self.add_csrf_to_request(request_builder)?; @@ -131,7 +126,7 @@ impl Jenkins { path: &Path, body: T, qps: &[(&str, &str)], - ) -> Result { + ) -> Result { let mut request_builder = self.client.post(&self.url(&path.to_string())); request_builder = self.add_csrf_to_request(request_builder)?; diff --git a/src/helpers.rs b/src/helpers.rs index 9f9838dc..b3694f77 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -20,7 +20,8 @@ macro_rules! specialize { ($common:ty => $trait:path) => { impl $common { #[doc = "Read the object as one of it's specialization implementing $trait"] - pub fn as_variant(&self) -> Result + #[allow(unused_qualifications)] + pub fn as_variant(&self) -> std::result::Result where for<'de> T: Deserialize<'de>, { diff --git a/src/home.rs b/src/home.rs index 0c2a0288..71bb2de2 100644 --- a/src/home.rs +++ b/src/home.rs @@ -1,9 +1,8 @@ //! Jenkins Home, describing state of the master -use failure::Error; use serde::Deserialize; -use crate::client_internals::Path; +use crate::client_internals::{Path, Result}; use crate::job::ShortJob; use crate::view::ShortView; use crate::Jenkins; @@ -48,7 +47,7 @@ pub struct Home { impl Jenkins { /// Get Jenkins `Home` - pub fn get_home(&self) -> Result { + pub fn get_home(&self) -> Result { Ok(self.get(&Path::Home)?.json()?) } } diff --git a/src/job/builder.rs b/src/job/builder.rs index 85226743..1c45ac9d 100644 --- a/src/job/builder.rs +++ b/src/job/builder.rs @@ -1,12 +1,11 @@ //! Helper to build a job -use failure::Error; use reqwest::header::LOCATION; use serde::{self, Serialize}; use serde_urlencoded; -use crate::client; +use crate::client::{self, Result}; use crate::client_internals::{Name, Path}; use crate::job::{Job, JobName}; use crate::queue::ShortQueueItem; @@ -25,7 +24,7 @@ pub struct JobBuilder<'a, 'b, 'c, 'd> { impl<'a, 'b, 'c, 'd> JobBuilder<'a, 'b, 'c, 'd> { #[allow(clippy::new_ret_no_self)] - pub(crate) fn new(job: &'a T, jenkins_client: &'b Jenkins) -> Result + pub(crate) fn new(job: &'a T, jenkins_client: &'b Jenkins) -> Result where T: Job, { @@ -52,7 +51,7 @@ impl<'a, 'b, 'c, 'd> JobBuilder<'a, 'b, 'c, 'd> { } } - pub(crate) fn new_from_job_name(name: J, jenkins_client: &'b Jenkins) -> Result + pub(crate) fn new_from_job_name(name: J, jenkins_client: &'b Jenkins) -> Result where J: Into>, { @@ -67,7 +66,7 @@ impl<'a, 'b, 'c, 'd> JobBuilder<'a, 'b, 'c, 'd> { } /// Trigger the build - pub fn send(self) -> Result { + pub fn send(self) -> Result { let response = match (self.token, self.parameters) { (Some(token), None) => { let bound_cause = self.cause.unwrap_or(""); @@ -145,7 +144,7 @@ impl<'a, 'b, 'c, 'd> JobBuilder<'a, 'b, 'c, 'd> { mut self, token: &'d str, cause: Option<&'c str>, - ) -> Result { + ) -> Result { if self.parameters.is_some() { return Err(client::Error::UnsupportedBuildConfiguration.into()); } @@ -168,7 +167,7 @@ impl<'a, 'b, 'c, 'd> JobBuilder<'a, 'b, 'c, 'd> { /// /// This methods will return an error if serializing `parameters` fails, or if passing /// parameters to a remote build. - pub fn with_parameters(mut self, parameters: &T) -> Result { + pub fn with_parameters(mut self, parameters: &T) -> Result { if self.token.is_some() { return Err(client::Error::UnsupportedBuildConfiguration.into()); } diff --git a/src/job/common.rs b/src/job/common.rs index 5dd6c2eb..a215fc1b 100644 --- a/src/job/common.rs +++ b/src/job/common.rs @@ -1,6 +1,5 @@ use std::marker::PhantomData; -use failure::Error; use serde::{self, Deserialize, Serialize}; use serde_json; @@ -9,7 +8,7 @@ use crate::helpers::Class; use super::JobBuilder; use crate::action::CommonAction; use crate::build::{CommonBuild, ShortBuild}; -use crate::client; +use crate::client::{self, Result}; use crate::client_internals::{Name, Path}; use crate::property::CommonProperty; use crate::queue::ShortQueueItem; @@ -88,7 +87,7 @@ where for<'de> T: Deserialize<'de>, { /// Get the full details of a `Job` matching the `ShortJob` - pub fn get_full_job(&self, jenkins_client: &Jenkins) -> Result { + pub fn get_full_job(&self, jenkins_client: &Jenkins) -> Result { let path = jenkins_client.url_to_path(&self.url); if let Path::Job { .. } = path { Ok(jenkins_client.get(&path)?.json()?) @@ -134,7 +133,7 @@ pub trait Job { fn name(&self) -> &str; /// Enable a `Job`. It may need to be refreshed as it may have been updated - fn enable(&self, jenkins_client: &Jenkins) -> Result<(), Error> { + fn enable(&self, jenkins_client: &Jenkins) -> Result<()> { let path = jenkins_client.url_to_path(&self.url()); if let Path::Job { name, @@ -153,7 +152,7 @@ pub trait Job { } /// Disable a `Job`. It may need to be refreshed as it may have been updated - fn disable(&self, jenkins_client: &Jenkins) -> Result<(), Error> { + fn disable(&self, jenkins_client: &Jenkins) -> Result<()> { let path = jenkins_client.url_to_path(&self.url()); if let Path::Job { name, @@ -172,7 +171,7 @@ pub trait Job { } /// Add this job to the view `view_name` - fn add_to_view<'a, V>(&self, jenkins_client: &Jenkins, view_name: V) -> Result<(), Error> + fn add_to_view<'a, V>(&self, jenkins_client: &Jenkins, view_name: V) -> Result<()> where V: Into>, { @@ -197,7 +196,7 @@ pub trait Job { } /// Remove this job from the view `view_name` - fn remove_from_view<'a, V>(&self, jenkins_client: &Jenkins, view_name: V) -> Result<(), Error> + fn remove_from_view<'a, V>(&self, jenkins_client: &Jenkins, view_name: V) -> Result<()> where V: Into>, { @@ -363,7 +362,7 @@ impl CommonJob {} /// Common trait for jobs that can be build pub trait BuildableJob: Job + Sized { /// Build this job - fn build(&self, jenkins_client: &Jenkins) -> Result { + fn build(&self, jenkins_client: &Jenkins) -> Result { self.builder(jenkins_client)?.send() } @@ -371,7 +370,7 @@ pub trait BuildableJob: Job + Sized { fn builder<'a, 'b, 'c, 'd>( &'a self, jenkins_client: &'b Jenkins, - ) -> Result, Error> { + ) -> Result> { JobBuilder::new(self, jenkins_client) } } @@ -379,7 +378,7 @@ pub trait BuildableJob: Job + Sized { /// Common trait for jobs that can poll a SCM pub trait SCMPollable: Job + Sized { /// Poll configured SCM for changes - fn poll_scm(&self, jenkins_client: &Jenkins) -> Result<(), Error> { + fn poll_scm(&self, jenkins_client: &Jenkins) -> Result<()> { let path = jenkins_client.url_to_path(&self.url()); if let Path::Job { name, diff --git a/src/job/mod.rs b/src/job/mod.rs index 6b11ea97..afa9a393 100644 --- a/src/job/mod.rs +++ b/src/job/mod.rs @@ -1,8 +1,6 @@ //! Jenkins Jobs -use failure::Error; - -use crate::client_internals::{Name, Path}; +use crate::client_internals::{Name, Path, Result}; use crate::queue::ShortQueueItem; use crate::Jenkins; @@ -31,7 +29,7 @@ pub use self::external::ExternalJob; impl Jenkins { /// Get a `Job` from it's `job_name` - pub fn get_job<'a, J>(&self, job_name: J) -> Result + pub fn get_job<'a, J>(&self, job_name: J) -> Result where J: Into>, { @@ -45,7 +43,7 @@ impl Jenkins { } /// Build a `Job` from it's `job_name` - pub fn build_job<'a, J>(&self, job_name: J) -> Result + pub fn build_job<'a, J>(&self, job_name: J) -> Result where J: Into>, { @@ -56,12 +54,12 @@ impl Jenkins { pub fn job_builder<'a, 'b, 'c, 'd>( &'b self, job_name: &'a str, - ) -> Result, Error> { + ) -> Result> { JobBuilder::new_from_job_name(job_name, self) } /// Poll SCM of a `Job` from it's `job_name` - pub fn poll_scm_job<'a, J>(&self, job_name: J) -> Result<(), Error> + pub fn poll_scm_job<'a, J>(&self, job_name: J) -> Result<()> where J: Into>, { diff --git a/src/lib.rs b/src/lib.rs index a02239a8..b756be5f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,13 +20,12 @@ //! # Example //! //! ```rust -//! extern crate failure; //! //! extern crate jenkins_api; //! //! use jenkins_api::JenkinsBuilder; //! -//! fn main() -> Result<(), failure::Error> { +//! fn main() -> Result<(), Box> { //! let jenkins = JenkinsBuilder::new("http://localhost:8080") //! .with_user("user", Some("password")) //! .build()?; @@ -43,22 +42,6 @@ //! ``` //! -// extern crate reqwest; - -// #[macro_use] -// use serde::{Serialize, Deserialize, self}; -// extern crate serde_json; -// extern crate serde_urlencoded; - -// extern crate urlencoding; - -// #[macro_use] -// extern crate failure; -// extern crate regex; - -// #[macro_use] -// extern crate log; - mod client_internals; pub use crate::client_internals::{Jenkins, JenkinsBuilder}; pub mod client; diff --git a/src/nodes/mod.rs b/src/nodes/mod.rs index 3f9f57dd..95f7942d 100644 --- a/src/nodes/mod.rs +++ b/src/nodes/mod.rs @@ -1,9 +1,8 @@ //! Jenkins Slaves Informations -use failure::Error; use serde::{Deserialize, Serialize}; -use crate::client_internals::{Name, Path}; +use crate::client_internals::{Name, Path, Result}; use crate::Jenkins; pub mod computer; @@ -26,12 +25,12 @@ pub struct ComputerSet { impl Jenkins { /// Get a `ComputerSet` - pub fn get_nodes(&self) -> Result { + pub fn get_nodes(&self) -> Result { Ok(self.get(&Path::Computers)?.json()?) } /// Get a `Computer` - pub fn get_node<'a, C>(&self, computer_name: C) -> Result + pub fn get_node<'a, C>(&self, computer_name: C) -> Result where C: Into>, { @@ -43,7 +42,7 @@ impl Jenkins { } /// Get the master `Computer` - pub fn get_master_node(&self) -> Result { + pub fn get_master_node(&self) -> Result { Ok(self .get(&Path::Computer { name: Name::Name("(master)"), diff --git a/src/queue.rs b/src/queue.rs index d0dec7ef..aa19bf2a 100644 --- a/src/queue.rs +++ b/src/queue.rs @@ -1,12 +1,11 @@ //! Jenkins build queue -use failure::Error; use serde::{Deserialize, Serialize}; use serde_json; use crate::action::CommonAction; use crate::build::ShortBuild; -use crate::client; +use crate::client::{self, Result}; use crate::client_internals::Path; use crate::job::ShortJob; use crate::Jenkins; @@ -21,7 +20,7 @@ pub struct ShortQueueItem { } impl ShortQueueItem { /// Get the full details of a `QueueItem` matching the `ShortQueueItem` - pub fn get_full_queue_item(&self, jenkins_client: &Jenkins) -> Result { + pub fn get_full_queue_item(&self, jenkins_client: &Jenkins) -> Result { let path = jenkins_client.url_to_path(&self.url); if let Path::QueueItem { .. } = path { Ok(jenkins_client.get(&path)?.json()?) @@ -68,7 +67,7 @@ pub struct QueueItem { } impl QueueItem { /// Refresh a `QueueItem`, consuming the existing one and returning a new `QueueItem` - pub fn refresh_item(self, jenkins_client: &Jenkins) -> Result { + pub fn refresh_item(self, jenkins_client: &Jenkins) -> Result { let path = jenkins_client.url_to_path(&self.url); if let Path::QueueItem { .. } = path { Ok(jenkins_client.get(&path)?.json()?) @@ -92,12 +91,12 @@ pub struct Queue { impl Jenkins { /// Get the Jenkins items queue - pub fn get_queue(&self) -> Result { + pub fn get_queue(&self) -> Result { Ok(self.get(&Path::Queue)?.json()?) } /// Get a queue item from it's ID - pub fn get_queue_item(&self, id: i32) -> Result { + pub fn get_queue_item(&self, id: i32) -> Result { Ok(self.get(&Path::QueueItem { id })?.json()?) } } diff --git a/src/view.rs b/src/view.rs index b6a7911e..6d6a116f 100644 --- a/src/view.rs +++ b/src/view.rs @@ -1,12 +1,11 @@ //! Jenkins Views, use to group Jobs -use failure::Error; use serde::{self, Deserialize, Serialize}; use serde_json; use crate::helpers::Class; -use crate::client; +use crate::client::{self, Result}; use crate::client_internals::{Name, Path}; use crate::job::{JobName, ShortJob}; use crate::property::CommonProperty; @@ -26,7 +25,7 @@ pub struct ShortView { impl ShortView { /// Get the full details of a `View` matching the `ShortView` - pub fn get_full_view(&self, jenkins_client: &Jenkins) -> Result { + pub fn get_full_view(&self, jenkins_client: &Jenkins) -> Result { let path = jenkins_client.url_to_path(&self.url); if let Path::View { .. } = path { Ok(jenkins_client.get(&path)?.json()?) @@ -121,7 +120,7 @@ impl View for ListView { impl ListView { /// Add the job `job_name` to this view - pub fn add_job<'a, J>(&self, jenkins_client: &Jenkins, job_name: J) -> Result<(), Error> + pub fn add_job<'a, J>(&self, jenkins_client: &Jenkins, job_name: J) -> Result<()> where J: Into>, { @@ -142,7 +141,7 @@ impl ListView { } /// Remove the job `job_name` from this view - pub fn remove_job<'a, J>(&self, jenkins_client: &Jenkins, job_name: J) -> Result<(), Error> + pub fn remove_job<'a, J>(&self, jenkins_client: &Jenkins, job_name: J) -> Result<()> where J: Into>, { @@ -165,7 +164,7 @@ impl ListView { impl Jenkins { /// Get a `View` - pub fn get_view<'a, V>(&self, view_name: V) -> Result + pub fn get_view<'a, V>(&self, view_name: V) -> Result where V: Into>, { @@ -177,7 +176,7 @@ impl Jenkins { } /// Add the job `job_name` to the view `view_name` - pub fn add_job_to_view<'a, 'b, V, J>(&self, view_name: V, job_name: J) -> Result<(), Error> + pub fn add_job_to_view<'a, 'b, V, J>(&self, view_name: V, job_name: J) -> Result<()> where V: Into>, J: Into>, @@ -190,7 +189,7 @@ impl Jenkins { } /// Remove the job `job_name` from the view `view_name` - pub fn remove_job_from_view<'a, 'b, V, J>(&self, view_name: V, job_name: J) -> Result<(), Error> + pub fn remove_job_from_view<'a, 'b, V, J>(&self, view_name: V, job_name: J) -> Result<()> where V: Into>, J: Into>, diff --git a/tests/client.rs b/tests/client.rs index 452183f0..0effa1f5 100644 --- a/tests/client.rs +++ b/tests/client.rs @@ -14,9 +14,9 @@ use jenkins_api::job::{BuildableJob, Job, SCMPollable}; use jenkins_api::JenkinsBuilder; use std::{thread, time}; -use std::sync::{Once, ONCE_INIT}; +use std::sync::Once; -static INIT: Once = ONCE_INIT; +static INIT: Once = Once::new(); fn setup() { INIT.call_once(|| { diff --git a/tests/propertied.rs b/tests/propertied.rs index b7974ae5..54994752 100644 --- a/tests/propertied.rs +++ b/tests/propertied.rs @@ -7,9 +7,9 @@ extern crate jenkins_api; use jenkins_api::JenkinsBuilder; -use std::sync::{Once, ONCE_INIT}; +use std::sync::Once; -static INIT: Once = ONCE_INIT; +static INIT: Once = Once::new(); fn setup() { INIT.call_once(|| {