Skip to content

Commit

Permalink
Add lots of derived Debug impls
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Jeffrey committed Oct 29, 2018
1 parent e580250 commit 05391e2
Show file tree
Hide file tree
Showing 23 changed files with 125 additions and 124 deletions.
16 changes: 8 additions & 8 deletions components/bluetooth_traits/lib.rs
Expand Up @@ -14,7 +14,7 @@ pub mod scanfilter;
use ipc_channel::ipc::IpcSender;
use scanfilter::{BluetoothScanfilterSequence, RequestDeviceoptions};

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub enum BluetoothError {
Type(String),
Network,
Expand All @@ -24,29 +24,29 @@ pub enum BluetoothError {
InvalidState,
}

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub enum GATTType {
PrimaryService,
Characteristic,
IncludedService,
Descriptor,
}

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub struct BluetoothDeviceMsg {
// Bluetooth Device properties
pub id: String,
pub name: Option<String>,
}

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub struct BluetoothServiceMsg {
pub uuid: String,
pub is_primary: bool,
pub instance_id: String,
}

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub struct BluetoothCharacteristicMsg {
// Characteristic
pub uuid: String,
Expand All @@ -63,7 +63,7 @@ pub struct BluetoothCharacteristicMsg {
pub writable_auxiliaries: bool,
}

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub struct BluetoothDescriptorMsg {
pub uuid: String,
pub instance_id: String,
Expand All @@ -79,7 +79,7 @@ pub type BluetoothResult<T> = Result<T, BluetoothError>;

pub type BluetoothResponseResult = Result<BluetoothResponse, BluetoothError>;

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub enum BluetoothRequest {
RequestDevice(RequestDeviceoptions, IpcSender<BluetoothResponseResult>),
GATTServerConnect(String, IpcSender<BluetoothResponseResult>),
Expand Down Expand Up @@ -107,7 +107,7 @@ pub enum BluetoothRequest {
Exit,
}

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub enum BluetoothResponse {
RequestDevice(BluetoothDeviceMsg),
GATTServerConnect(bool),
Expand Down
8 changes: 4 additions & 4 deletions components/bluetooth_traits/scanfilter.rs
Expand Up @@ -10,7 +10,7 @@ use std::slice::Iter;
// That leaves 29 bytes for the name.
const MAX_NAME_LENGTH: usize = 29;

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub struct ServiceUUIDSequence(Vec<String>);

impl ServiceUUIDSequence {
Expand All @@ -26,7 +26,7 @@ impl ServiceUUIDSequence {
type ManufacturerData = HashMap<u16, (Vec<u8>, Vec<u8>)>;
type ServiceData = HashMap<String, (Vec<u8>, Vec<u8>)>;

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub struct BluetoothScanfilter {
name: Option<String>,
name_prefix: String,
Expand Down Expand Up @@ -83,7 +83,7 @@ impl BluetoothScanfilter {
}
}

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub struct BluetoothScanfilterSequence(Vec<BluetoothScanfilter>);

impl BluetoothScanfilterSequence {
Expand All @@ -110,7 +110,7 @@ impl BluetoothScanfilterSequence {
}
}

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub struct RequestDeviceoptions {
filters: BluetoothScanfilterSequence,
optional_services: ServiceUUIDSequence,
Expand Down
34 changes: 17 additions & 17 deletions components/canvas_traits/canvas.rs
Expand Up @@ -10,13 +10,13 @@ use std::default::Default;
use std::str::FromStr;
use webrender_api;

#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum FillRule {
Nonzero,
Evenodd,
}

#[derive(Clone, Copy, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)]
pub struct CanvasId(pub u64);

#[derive(Deserialize, Serialize)]
Expand All @@ -30,12 +30,12 @@ pub enum CanvasMsg {
Exit,
}

#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CanvasImageData {
pub image_key: webrender_api::ImageKey,
}

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub enum Canvas2dMsg {
Arc(Point2D<f32>, f32, f32, f32, bool),
ArcTo(Point2D<f32>, Point2D<f32>, f32),
Expand Down Expand Up @@ -77,23 +77,23 @@ pub enum Canvas2dMsg {
SetShadowColor(RGBA),
}

#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum FromLayoutMsg {
SendData(IpcSender<CanvasImageData>),
}

#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum FromScriptMsg {
SendPixels(IpcSender<Option<ByteBuf>>),
}

#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
pub struct CanvasGradientStop {
pub offset: f64,
pub color: RGBA,
}

#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
pub struct LinearGradientStyle {
pub x0: f64,
pub y0: f64,
Expand All @@ -115,7 +115,7 @@ impl LinearGradientStyle {
}
}

#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
pub struct RadialGradientStyle {
pub x0: f64,
pub y0: f64,
Expand All @@ -141,7 +141,7 @@ impl RadialGradientStyle {
}
}

#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SurfaceStyle {
pub surface_data: ByteBuf,
pub surface_size: Size2D<u32>,
Expand All @@ -166,15 +166,15 @@ impl SurfaceStyle {
}


#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum FillOrStrokeStyle {
Color(RGBA),
LinearGradient(LinearGradientStyle),
RadialGradient(RadialGradientStyle),
Surface(SurfaceStyle),
}

#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
pub enum LineCapStyle {
Butt = 0,
Round = 1,
Expand All @@ -194,7 +194,7 @@ impl FromStr for LineCapStyle {
}
}

#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
pub enum LineJoinStyle {
Round = 0,
Bevel = 1,
Expand All @@ -214,7 +214,7 @@ impl FromStr for LineJoinStyle {
}
}

#[derive(Clone, Copy, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum RepetitionStyle {
Repeat,
RepeatX,
Expand All @@ -236,7 +236,7 @@ impl FromStr for RepetitionStyle {
}
}

#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
pub enum CompositionStyle {
SrcIn,
SrcOut,
Expand Down Expand Up @@ -290,7 +290,7 @@ impl CompositionStyle {
}
}

#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
pub enum BlendingStyle {
Multiply,
Screen,
Expand Down Expand Up @@ -356,7 +356,7 @@ impl BlendingStyle {
}
}

#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
pub enum CompositionOrBlending {
Composition(CompositionStyle),
Blending(BlendingStyle),
Expand Down
24 changes: 12 additions & 12 deletions components/canvas_traits/webgl.rs
Expand Up @@ -24,7 +24,7 @@ pub use ::webgl_channel::WebGLPipeline;
/// Entry point channel type used for sending WebGLMsg messages to the WebGL renderer.
pub use ::webgl_channel::WebGLChan;

#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WebGLCommandBacktrace {
#[cfg(feature = "webgl_backtrace")]
pub backtrace: String,
Expand All @@ -33,7 +33,7 @@ pub struct WebGLCommandBacktrace {
}

/// WebGL Message API
#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub enum WebGLMsg {
/// Creates a new WebGLContext.
CreateContext(
Expand Down Expand Up @@ -70,7 +70,7 @@ pub enum WebGLMsg {
}

/// Contains the WebGLCommand sender and information about a WebGLContext
#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WebGLCreateContextResult {
/// Sender instance to send commands to the specific WebGLContext
pub sender: WebGLMsgSender,
Expand All @@ -82,7 +82,7 @@ pub struct WebGLCreateContextResult {
pub glsl_version: WebGLSLVersion,
}

#[derive(Clone, Copy, Deserialize, MallocSizeOf, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, Serialize)]
pub enum WebGLContextShareMode {
/// Fast: a shared texture_id is used in WebRender.
SharedTexture,
Expand All @@ -91,7 +91,7 @@ pub enum WebGLContextShareMode {
}

/// Defines the WebGL version
#[derive(Clone, Copy, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)]
pub enum WebGLVersion {
/// https://www.khronos.org/registry/webgl/specs/1.0.2/
/// Conforms closely to the OpenGL ES 2.0 API
Expand All @@ -102,7 +102,7 @@ pub enum WebGLVersion {
}

/// Defines the GLSL version supported by the WebGL backend contexts.
#[derive(Clone, Copy, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)]
pub struct WebGLSLVersion {
/// Major GLSL version
pub major: u32,
Expand All @@ -111,7 +111,7 @@ pub struct WebGLSLVersion {
}

/// Helper struct to send WebGLCommands to a specific WebGLContext.
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
pub struct WebGLMsgSender {
ctx_id: WebGLContextId,
#[ignore_malloc_size_of = "channels are hard"]
Expand Down Expand Up @@ -414,7 +414,7 @@ pub type WebGLResult<T> = Result<T, WebGLError>;
pub type WebVRDeviceId = u32;

// WebVR commands that must be called in the WebGL render thread.
#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum WebVRCommand {
/// Start presenting to a VR device.
Create(WebVRDeviceId),
Expand All @@ -433,7 +433,7 @@ pub trait WebVRRenderHandler: Send {
}

/// WebGL commands required to implement DOMToTexture feature.
#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum DOMToTextureCommand {
/// Attaches a HTMLIFrameElement to a WebGLTexture.
Attach(WebGLContextId, WebGLTextureId, DocumentId, PipelineId, Size2D<i32>),
Expand All @@ -444,7 +444,7 @@ pub enum DOMToTextureCommand {
}

/// Information about a WebGL program linking operation.
#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ProgramLinkInfo {
/// Whether the program was linked successfully.
pub linked: bool,
Expand All @@ -455,7 +455,7 @@ pub struct ProgramLinkInfo {
}

/// Description of a single active attribute.
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
pub struct ActiveAttribInfo {
/// The name of the attribute.
pub name: String,
Expand All @@ -468,7 +468,7 @@ pub struct ActiveAttribInfo {
}

/// Description of a single active uniform.
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
pub struct ActiveUniformInfo {
/// The base name of the uniform.
pub base_name: Box<str>,
Expand Down
4 changes: 2 additions & 2 deletions components/canvas_traits/webgl_channel/mod.rs
Expand Up @@ -85,7 +85,7 @@ where
}
}

#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WebGLChan(pub WebGLSender<WebGLMsg>);

impl WebGLChan {
Expand All @@ -95,7 +95,7 @@ impl WebGLChan {
}
}

#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WebGLPipeline(pub WebGLChan);

impl WebGLPipeline {
Expand Down
4 changes: 2 additions & 2 deletions components/config/opts.rs
Expand Up @@ -23,7 +23,7 @@ use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
use url::{self, Url};

/// Global flags for Servo, currently set on the command line.
#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Opts {
pub is_running_problem_test: bool,

Expand Down Expand Up @@ -474,7 +474,7 @@ fn print_debug_usage(app: &str) -> ! {
process::exit(0)
}

#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum OutputOptions {
/// Database connection config (hostname, name, user, pass)
DB(ServoUrl, Option<String>, Option<String>, Option<String>),
Expand Down
1 change: 1 addition & 0 deletions components/constellation/constellation.rs
Expand Up @@ -864,6 +864,7 @@ where

/// Handles loading pages, navigation, and granting access to the compositor
fn handle_request(&mut self) {
#[derive(Debug)]
enum Request {
Script((PipelineId, FromScriptMsg)),
Compositor(FromCompositorMsg),
Expand Down

0 comments on commit 05391e2

Please sign in to comment.