Skip to content
This repository has been archived by the owner on Apr 1, 2019. It is now read-only.

Use derive debug for custom enum and struct definitions #111

Merged
merged 1 commit into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_serialize::json::{ToJson, Json};
use std::collections::BTreeMap;
use std::default::Default;

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub enum WebDriverCommand<T: WebDriverExtensionCommand> {
NewSession(NewSessionParameters),
DeleteSession,
Expand Down Expand Up @@ -74,7 +74,7 @@ pub trait WebDriverExtensionCommand : Clone + Send + PartialEq {
fn parameters_json(&self) -> Option<Json>;
}

#[derive(Clone, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct VoidWebDriverExtensionCommand;

impl WebDriverExtensionCommand for VoidWebDriverExtensionCommand {
Expand All @@ -83,7 +83,7 @@ impl WebDriverExtensionCommand for VoidWebDriverExtensionCommand {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct WebDriverMessage <U: WebDriverExtensionRoute=VoidWebDriverExtensionRoute> {
pub session_id: Option<String>,
pub command: WebDriverCommand<U::Command>,
Expand Down Expand Up @@ -490,7 +490,7 @@ impl CapabilitiesMatching for NewSessionParameters {
}


#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct GetParameters {
pub url: String
}
Expand Down Expand Up @@ -519,7 +519,7 @@ impl ToJson for GetParameters {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct TimeoutsParameters {
pub script: Option<u64>,
pub page_load: Option<u64>,
Expand Down Expand Up @@ -658,7 +658,7 @@ impl ToJson for WindowRectParameters {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct SwitchToWindowParameters {
pub handle: String
}
Expand Down Expand Up @@ -687,7 +687,7 @@ impl ToJson for SwitchToWindowParameters {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct LocatorParameters {
pub using: LocatorStrategy,
pub value: String
Expand Down Expand Up @@ -726,7 +726,7 @@ impl ToJson for LocatorParameters {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct SwitchToFrameParameters {
pub id: FrameId
}
Expand Down Expand Up @@ -754,7 +754,7 @@ impl ToJson for SwitchToFrameParameters {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct SendKeysParameters {
pub text: String
}
Expand Down Expand Up @@ -784,7 +784,7 @@ impl ToJson for SendKeysParameters {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct JavascriptCommandParameters {
pub script: String,
pub args: Nullable<Vec<Json>>
Expand Down Expand Up @@ -832,7 +832,7 @@ impl ToJson for JavascriptCommandParameters {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct GetNamedCookieParameters {
pub name: Nullable<String>,
}
Expand Down Expand Up @@ -863,7 +863,7 @@ impl ToJson for GetNamedCookieParameters {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct AddCookieParameters {
pub name: String,
pub value: String,
Expand Down Expand Up @@ -978,7 +978,7 @@ impl ToJson for AddCookieParameters {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct TakeScreenshotParameters {
pub element: Nullable<WebElement>
}
Expand Down Expand Up @@ -1011,7 +1011,7 @@ impl ToJson for TakeScreenshotParameters {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct ActionsParameters {
pub actions: Vec<ActionSequence>
}
Expand Down Expand Up @@ -1047,7 +1047,7 @@ impl ToJson for ActionsParameters {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct ActionSequence {
pub id: Nullable<String>,
pub actions: ActionsType
Expand Down Expand Up @@ -1113,7 +1113,7 @@ impl ToJson for ActionSequence {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub enum ActionsType {
Null(Vec<NullActionItem>),
Key(Vec<KeyActionItem>),
Expand Down Expand Up @@ -1162,7 +1162,7 @@ impl Parameters for ActionsType {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub enum PointerType {
Mouse,
Pen,
Expand Down Expand Up @@ -1203,7 +1203,7 @@ impl Default for PointerType {
}
}

#[derive(Default, PartialEq)]
#[derive(Debug, Default, PartialEq)]
pub struct PointerActionParameters {
pub pointer_type: PointerType
}
Expand Down Expand Up @@ -1232,7 +1232,7 @@ impl ToJson for PointerActionParameters {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub enum NullActionItem {
General(GeneralAction)
}
Expand Down Expand Up @@ -1265,7 +1265,7 @@ impl ToJson for NullActionItem {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub enum KeyActionItem {
General(GeneralAction),
Key(KeyAction)
Expand Down Expand Up @@ -1300,7 +1300,7 @@ impl ToJson for KeyActionItem {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub enum PointerActionItem {
General(GeneralAction),
Pointer(PointerAction)
Expand Down Expand Up @@ -1334,7 +1334,7 @@ impl ToJson for PointerActionItem {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub enum GeneralAction {
Pause(PauseAction)
}
Expand All @@ -1357,7 +1357,7 @@ impl ToJson for GeneralAction {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct PauseAction {
pub duration: u64
}
Expand All @@ -1384,7 +1384,7 @@ impl ToJson for PauseAction {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub enum KeyAction {
Up(KeyUpAction),
Down(KeyDownAction)
Expand Down Expand Up @@ -1427,7 +1427,7 @@ fn validate_key_value(value_str: &str) -> WebDriverResult<char> {
Ok(value)
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct KeyUpAction {
pub value: char
}
Expand Down Expand Up @@ -1459,7 +1459,7 @@ impl ToJson for KeyUpAction {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct KeyDownAction {
pub value: char
}
Expand Down Expand Up @@ -1490,7 +1490,7 @@ impl ToJson for KeyDownAction {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub enum PointerOrigin {
Viewport,
Pointer,
Expand Down Expand Up @@ -1531,7 +1531,7 @@ impl Default for PointerOrigin {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub enum PointerAction {
Up(PointerUpAction),
Down(PointerDownAction),
Expand Down Expand Up @@ -1569,7 +1569,7 @@ impl ToJson for PointerAction {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct PointerUpAction {
pub button: u64,
}
Expand Down Expand Up @@ -1599,7 +1599,7 @@ impl ToJson for PointerUpAction {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct PointerDownAction {
pub button: u64,
}
Expand Down Expand Up @@ -1629,7 +1629,7 @@ impl ToJson for PointerDownAction {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub struct PointerMoveAction {
pub duration: Nullable<u64>,
pub origin: PointerOrigin,
Expand Down
8 changes: 4 additions & 4 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use error::{WebDriverResult, WebDriverError, ErrorStatus};

pub static ELEMENT_KEY: &'static str = "element-6066-11e4-a52e-4f735466cecf";

#[derive(RustcEncodable, PartialEq, Clone, Debug)]
#[derive(Clone, Debug, PartialEq, RustcEncodable)]
pub struct Date(pub u64);

impl Date {
Expand All @@ -22,7 +22,7 @@ impl ToJson for Date {
}
}

#[derive(PartialEq, Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
pub enum Nullable<T: ToJson> {
Value(T),
Null
Expand Down Expand Up @@ -142,7 +142,7 @@ impl <T> From<T> for WebElement
}
}

#[derive(PartialEq, Debug)]
#[derive(Debug, PartialEq)]
pub enum FrameId {
Short(u16),
Element(WebElement),
Expand Down Expand Up @@ -184,7 +184,7 @@ impl ToJson for FrameId {
}
}

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub enum LocatorStrategy {
CSSSelector,
LinkText,
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::error::Error;
use std::fmt;
use std::io;

#[derive(PartialEq, Debug)]
#[derive(Debug, PartialEq)]
pub enum ErrorStatus {
/// The [`ElementClick`] command could not be completed because the
/// [element] receiving the events is obscuring the element that was
Expand Down
7 changes: 4 additions & 3 deletions src/httpapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn standard_routes<U:WebDriverExtensionRoute>() -> Vec<(Method, &'static str, Ro
(Get, "/status", Route::Status),]
}

#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug)]
pub enum Route<U:WebDriverExtensionRoute> {
NewSession,
DeleteSession,
Expand Down Expand Up @@ -142,7 +142,7 @@ pub trait WebDriverExtensionRoute : Clone + Send + PartialEq {
fn command(&self, &Captures, &Json) -> WebDriverResult<WebDriverCommand<Self::Command>>;
}

#[derive(Clone, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct VoidWebDriverExtensionRoute;

impl WebDriverExtensionRoute for VoidWebDriverExtensionRoute {
Expand All @@ -153,7 +153,7 @@ impl WebDriverExtensionRoute for VoidWebDriverExtensionRoute {
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
struct RequestMatcher<U: WebDriverExtensionRoute> {
method: Method,
path_regexp: Regex,
Expand Down Expand Up @@ -197,6 +197,7 @@ impl <U: WebDriverExtensionRoute> RequestMatcher<U> {
}
}

#[derive(Debug)]
pub struct WebDriverHttpApi<U: WebDriverExtensionRoute> {
routes: Vec<(Method, RequestMatcher<U>)>,
}
Expand Down
Loading