Skip to content

Commit

Permalink
Derive additional impls where possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmycuadra committed Dec 15, 2018
1 parent 956e5e0 commit 775eaf1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ use crate::error::{ApiError, Error};
use crate::first_ok::first_ok;

/// The structure returned by the `GET /v2/auth/enable` endpoint.
#[derive(Debug, Deserialize)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
struct AuthStatus {
/// Whether or not the auth system is enabled.
pub enabled: bool,
}

/// The type returned when the auth system is successfully enabled or disabled.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum AuthChange {
/// The auth system was successfully enabled or disabled.
Changed,
Expand All @@ -31,7 +31,7 @@ pub enum AuthChange {
}

/// An existing etcd user with a list of their granted roles.
#[derive(Debug, Clone, Deserialize, Eq, Hash, PartialEq)]
#[derive(Debug, Clone, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct User {
/// The user's name.
#[serde(rename = "user")]
Expand All @@ -53,7 +53,7 @@ impl User {
}

/// An existing etcd user with details of granted roles.
#[derive(Debug, Clone, Deserialize, Eq, Hash, PartialEq)]
#[derive(Debug, Clone, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct UserDetail {
/// The user's name.
#[serde(rename = "user")]
Expand All @@ -75,13 +75,13 @@ impl UserDetail {
}

/// A list of all users.
#[derive(Debug, Clone, Deserialize, Eq, Hash, PartialEq)]
#[derive(Debug, Clone, Deserialize, Eq, Hash, PartialEq, Serialize)]
struct Users {
users: Option<Vec<UserDetail>>,
}

/// Paramters used to create a new etcd user.
#[derive(Debug, Clone, Eq, Hash, PartialEq, Serialize)]
#[derive(Debug, Deserialize, Clone, Eq, Hash, PartialEq, Serialize)]
pub struct NewUser {
/// The user's name.
#[serde(rename = "user")]
Expand Down Expand Up @@ -125,7 +125,7 @@ impl NewUser {
}

/// Parameters used to update an existing etcd user.
#[derive(Debug, Clone, Eq, Hash, PartialEq, Serialize)]
#[derive(Debug, Deserialize, Clone, Eq, Hash, PartialEq, Serialize)]
pub struct UserUpdate {
/// The user's name.
#[serde(rename = "user")]
Expand Down Expand Up @@ -254,13 +254,13 @@ impl Role {
}

/// A list of all roles.
#[derive(Debug, Clone, Deserialize, Eq, Hash, PartialEq)]
#[derive(Debug, Clone, Deserialize, Eq, Hash, PartialEq, Serialize)]
struct Roles {
roles: Option<Vec<Role>>,
}

/// Parameters used to update an existing authorization role.
#[derive(Debug, Clone, Eq, Hash, PartialEq, Serialize)]
#[derive(Debug, Deserialize, Clone, Eq, Hash, PartialEq, Serialize)]
pub struct RoleUpdate {
/// The name of the role.
#[serde(rename = "role")]
Expand Down
6 changes: 3 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use hyper::{Client as Hyper, StatusCode, Uri};
use hyper_tls::HttpsConnector;
use log::error;
use serde::de::DeserializeOwned;
use serde_derive::Deserialize;
use serde_derive::{Deserialize, Serialize};
use serde_json;

use crate::error::{ApiError, Error};
Expand Down Expand Up @@ -62,7 +62,7 @@ pub struct BasicAuth {
}

/// A value returned by the health check API endpoint to indicate a healthy cluster member.
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Health {
/// The health status of the cluster member.
pub health: String,
Expand Down Expand Up @@ -330,7 +330,7 @@ pub struct Response<T> {
}

/// Information about the state of the etcd cluster from an API response's HTTP headers.
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ClusterInfo {
/// An internal identifier for the cluster.
pub cluster_id: Option<String>,
Expand Down
6 changes: 3 additions & 3 deletions src/members.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::error::{ApiError, Error};
use crate::first_ok::first_ok;

/// An etcd server that is a member of a cluster.
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Member {
/// An internal identifier for the cluster member.
pub id: String,
Expand All @@ -30,15 +30,15 @@ pub struct Member {
}

/// The request body for `POST /v2/members` and `PUT /v2/members/:id`.
#[derive(Debug, Serialize)]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
struct PeerUrls {
/// The peer URLs.
#[serde(rename = "peerURLs")]
peer_urls: Vec<String>,
}

/// A small wrapper around `Member` to match the response of `GET /v2/members`.
#[derive(Debug, Deserialize)]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
struct ListResponse {
/// The members.
members: Vec<Member>,
Expand Down
10 changes: 5 additions & 5 deletions src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::client::{Client, Response};
use crate::error::Error;

/// Statistics about an etcd cluster leader.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct LeaderStats {
/// A unique identifier of a leader member.
pub leader: String,
Expand All @@ -21,7 +21,7 @@ pub struct LeaderStats {
}

/// Statistics about the health of a single etcd follower node.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct FollowerStats {
/// Counts of Raft RPC request successes and failures to this follower.
pub counts: CountStats,
Expand All @@ -30,7 +30,7 @@ pub struct FollowerStats {
}

/// Statistics about the number of successful and failed Raft RPC requests to an etcd node.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct CountStats {
/// The number of times an RPC request to the node failed.
pub fail: u64,
Expand All @@ -39,7 +39,7 @@ pub struct CountStats {
}

/// Statistics about the network latency to an etcd node.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct LatencyStats {
/// The average observed latency to the node, in seconds.
pub average: f64,
Expand All @@ -55,7 +55,7 @@ pub struct LatencyStats {
}

/// Statistics about an etcd cluster member.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct SelfStats {
/// The unique Raft ID of the member.
pub id: String,
Expand Down

0 comments on commit 775eaf1

Please sign in to comment.