Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid missing Debug implementations #673

Merged
merged 4 commits into from
Oct 13, 2019
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
29 changes: 26 additions & 3 deletions src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<T: Serialize + for<'de> Deserialize<'de>> Packed for T {
type SharedOutputSlab<AGN> = Shared<Slab<Option<Callback<<AGN as Agent>::Output>>>>;

/// Id of responses handler.
#[derive(Serialize, Deserialize, Eq, PartialEq, Hash, Clone, Copy)]
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Hash, Clone, Copy)]
pub struct HandlerId(usize, bool);

impl HandlerId {
Expand Down Expand Up @@ -249,6 +249,7 @@ thread_local! {
}

/// Create a single instance in the current thread.
#[allow(missing_debug_implementations)]
pub struct Context;

impl Discoverer for Context {
Expand Down Expand Up @@ -344,6 +345,7 @@ impl<AGN: Agent> Drop for ContextBridge<AGN> {
}

/// Create an instance in the current thread.
#[allow(missing_debug_implementations)]
pub struct Job;

impl Discoverer for Job {
Expand Down Expand Up @@ -397,6 +399,7 @@ impl<AGN: Agent> Drop for JobBridge<AGN> {
// <<< SEPARATE THREAD >>>

/// Create a new instance for every bridge.
#[allow(missing_debug_implementations)]
pub struct Private;

impl Discoverer for Private {
Expand Down Expand Up @@ -438,6 +441,12 @@ pub struct PrivateBridge<T: Agent> {
_agent: PhantomData<T>,
}

impl<AGN: Agent> fmt::Debug for PrivateBridge<AGN> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("PrivateBridge<_>")
}
}

impl<AGN: Agent> Bridge<AGN> for PrivateBridge<AGN> {
fn send(&mut self, msg: AGN::Input) {
// TODO Important! Implement.
Expand Down Expand Up @@ -494,6 +503,7 @@ thread_local! {
}

/// Create a single instance in a tab.
#[allow(missing_debug_implementations)]
pub struct Public;

impl Discoverer for Public {
Expand Down Expand Up @@ -555,10 +565,16 @@ impl Discoverer for Public {
impl Dispatchable for Public {}

/// A connection manager for components interaction with workers.
pub struct PublicBridge<T: Agent> {
pub struct PublicBridge<AGN: Agent> {
worker: Value,
id: HandlerId,
_agent: PhantomData<T>,
_agent: PhantomData<AGN>,
}

impl<AGN: Agent> fmt::Debug for PublicBridge<AGN> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("PublicBridge<_>")
}
}

impl<AGN: Agent> PublicBridge<AGN> {
Expand Down Expand Up @@ -636,6 +652,7 @@ impl<AGN: Agent> Drop for PublicBridge<AGN> {
}

/// Create a single instance in a browser.
#[allow(missing_debug_implementations)]
pub struct Global;

impl Discoverer for Global {}
Expand Down Expand Up @@ -681,6 +698,12 @@ pub struct AgentScope<AGN: Agent> {
shared_agent: Shared<AgentRunnable<AGN>>,
}

impl<AGN: Agent> fmt::Debug for AgentScope<AGN> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("AgentScope<_>")
}
}

impl<AGN: Agent> Clone for AgentScope<AGN> {
fn clone(&self) -> Self {
AgentScope {
Expand Down
1 change: 1 addition & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::html::{Component, Renderable, Scope};
use stdweb::web::{document, Element, INode, IParentNode};

/// An application instance.
#[derive(Debug)]
pub struct App<COMP: Component> {
/// `Scope` holder
scope: Scope<COMP>,
Expand Down
4 changes: 3 additions & 1 deletion src/components/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ use crate::html::{ChangeData, Component, ComponentLink, Html, Renderable, Should
use crate::macros::{html, Properties};

/// `Select` component.
#[derive(Debug)]
pub struct Select<T> {
props: Props<T>,
}

/// Internal message of the component.
#[derive(Debug)]
pub enum Msg {
/// This message indicates the option with id selected.
Selected(Option<usize>),
}

/// Properties of `Select` component.
#[derive(PartialEq, Properties)]
#[derive(PartialEq, Properties, Debug)]
pub struct Props<T> {
/// Initially selected value.
pub selected: Option<T>,
Expand Down
1 change: 1 addition & 0 deletions src/format/cbor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use serde_cbor;
/// // Converts CBOR string to a data (lazy).
/// let Cbor(data) = dump;
/// ```
#[derive(Debug)]
pub struct Cbor<T>(pub T);

binary_format!(Cbor based on serde_cbor);
1 change: 1 addition & 0 deletions src/format/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/// // Converts JSON string to a data (lazy).
/// let Json(data) = dump;
/// ```
#[derive(Debug)]
pub struct Json<T>(pub T);

text_format!(Json based on serde_json);
Expand Down
1 change: 1 addition & 0 deletions src/format/msgpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use rmp_serde;
/// // Converts MessagePack string to a data (lazy).
/// let MsgPack(data) = dump;
/// ```
#[derive(Debug)]
pub struct MsgPack<T>(pub T);

binary_format!(MsgPack based on rmp_serde);
1 change: 1 addition & 0 deletions src/format/nothing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use super::{Binary, Text};
use failure::err_msg;

/// A representation of an empty data. Nothing stored. Nothing restored.
#[derive(Debug)]
pub struct Nothing;

impl Into<Text> for Nothing {
Expand Down
1 change: 1 addition & 0 deletions src/format/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use toml;
/// // Converts TOML string to a data (lazy).
/// let Toml(data) = dump;
/// ```
#[derive(Debug)]
pub struct Toml<T>(pub T);

text_format!(Toml based on toml);
Expand Down
1 change: 1 addition & 0 deletions src/format/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use serde_yaml;
/// // Converts YAML string to a data (lazy).
/// let Yaml(data) = dump;
/// ```
#[derive(Debug)]
pub struct Yaml<T>(pub T);

text_format!(Yaml based on serde_yaml);
Expand Down
1 change: 1 addition & 0 deletions src/html/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ macro_rules! impl_action {

/// A wrapper for a callback.
/// Listener extracted from here when attached.
#[allow(missing_debug_implementations)]
jstarry marked this conversation as resolved.
Show resolved Hide resolved
pub struct Wrapper<F>(Option<F>);

/// And event type which keeps the returned type.
Expand Down
1 change: 1 addition & 0 deletions src/html/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ pub trait Properties {
}

/// Builder for when a component has no properties
#[derive(Debug)]
pub struct EmptyBuilder;

impl Properties for () {
Expand Down
6 changes: 6 additions & 0 deletions src/html/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ pub struct Scope<COMP: Component> {
shared_state: Shared<ComponentState<COMP>>,
}

impl<COMP: Component> fmt::Debug for Scope<COMP> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("Scope<_>")
}
}

impl<COMP: Component> Clone for Scope<COMP> {
fn clone(&self) -> Self {
Scope {
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

#![deny(
missing_docs,
missing_debug_implementations,
bare_trait_objects,
anonymous_parameters,
elided_lifetimes_in_paths
Expand Down
2 changes: 1 addition & 1 deletion src/services/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use stdweb::{_js_impl, js};

/// A service to use methods of a
/// [Console](https://developer.mozilla.org/en-US/docs/Web/API/Console).
#[derive(Default)]
#[derive(Default, Debug)]
pub struct ConsoleService {}

impl ConsoleService {
Expand Down
2 changes: 1 addition & 1 deletion src/services/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use stdweb::Value;
use stdweb::{_js_impl, js};

/// A dialog service.
#[derive(Default)]
#[derive(Default, Debug)]
pub struct DialogService {}

impl DialogService {
Expand Down
19 changes: 13 additions & 6 deletions src/services/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::format::{Binary, Format, Text};
use failure::Fail;
use serde::Serialize;
use std::collections::HashMap;
use std::fmt;
use stdweb::serde::Serde;
use stdweb::unstable::{TryFrom, TryInto};
use stdweb::web::ArrayBuffer;
Expand All @@ -16,7 +17,7 @@ use stdweb::{_js_impl, js};
pub use http::{HeaderMap, Method, Request, Response, StatusCode, Uri};

/// Type to set cache for fetch.
#[derive(Serialize)]
#[derive(Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum Cache {
/// `default` value of cache.
Expand All @@ -35,7 +36,7 @@ pub enum Cache {
}

/// Type to set credentials for fetch.
#[derive(Serialize)]
#[derive(Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum Credentials {
/// `omit` value of credentials.
Expand All @@ -47,7 +48,7 @@ pub enum Credentials {
}

/// Type to set mode for fetch.
#[derive(Serialize)]
#[derive(Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum Mode {
/// `same-origin` value of mode.
Expand All @@ -59,7 +60,7 @@ pub enum Mode {
}

/// Type to set redirect behaviour for fetch.
#[derive(Serialize)]
#[derive(Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum Redirect {
/// `follow` value of redirect.
Expand All @@ -72,7 +73,7 @@ pub enum Redirect {

/// Init options for `fetch()` function call.
/// https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch
#[derive(Serialize, Default)]
#[derive(Serialize, Default, Debug)]
pub struct FetchOptions {
/// Cache of a fetch request.
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -99,8 +100,14 @@ enum FetchError {
#[must_use]
pub struct FetchTask(Option<Value>);

impl fmt::Debug for FetchTask {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("FetchTask")
}
}

/// A service to fetch resources.
#[derive(Default)]
#[derive(Default, Debug)]
pub struct FetchService {}

impl FetchService {
Expand Down
9 changes: 8 additions & 1 deletion src/services/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use super::{to_ms, Task};
use crate::callback::Callback;
use std::fmt;
use std::time::Duration;
use stdweb::Value;
#[allow(unused_imports)]
Expand All @@ -13,8 +14,14 @@ use stdweb::{_js_impl, js};
#[must_use]
pub struct IntervalTask(Option<Value>);

impl fmt::Debug for IntervalTask {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("IntervalTask")
}
}

/// A service to send messages on every elapsed interval.
#[derive(Default)]
#[derive(Default, Debug)]
pub struct IntervalService {}

impl IntervalService {
Expand Down
8 changes: 8 additions & 0 deletions src/services/keyboard.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Service to register key press event listeners on elements.
use crate::callback::Callback;
use std::fmt;
use stdweb::web::event::{KeyDownEvent, KeyPressEvent, KeyUpEvent};
use stdweb::web::{EventListenerHandle, IEventTarget};

Expand All @@ -12,13 +13,20 @@ use stdweb::web::{EventListenerHandle, IEventTarget};
///
/// This service is for adding key event listeners to elements that don't support these attributes,
/// like the `document` or `<canvas>` elements for example.
#[derive(Debug)]
pub struct KeyboardService {}

/// Handle to the key event listener.
///
/// When it goes out of scope, the listener will be removed from the element.
pub struct KeyListenerHandle(Option<EventListenerHandle>);

impl fmt::Debug for KeyListenerHandle {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("KeyListenerHandle")
}
}

impl KeyboardService {
/// Registers a callback that listens to KeyPressEvents on a provided element.
///
Expand Down
9 changes: 8 additions & 1 deletion src/services/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use super::Task;
use crate::callback::Callback;
use std::cmp;
use std::fmt;
use stdweb::unstable::TryInto;
use stdweb::web::event::LoadEndEvent;
pub use stdweb::web::{Blob, File, IBlob};
Expand Down Expand Up @@ -39,7 +40,7 @@ pub enum FileChunk {
}

/// A reader service attached to a user context.
#[derive(Default)]
#[derive(Default, Debug)]
pub struct ReaderService {}

impl ReaderService {
Expand Down Expand Up @@ -135,6 +136,12 @@ pub struct ReaderTask {
file_reader: FileReader,
}

impl fmt::Debug for ReaderTask {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("ReaderTask")
}
}

impl Task for ReaderTask {
fn is_active(&self) -> bool {
self.file_reader.ready_state() == FileReaderReadyState::Loading
Expand Down
Loading