Index: Cargo.toml ================================================================== --- Cargo.toml +++ Cargo.toml @@ -22,11 +22,11 @@ tokio = ["dep:tokio", "dep:async-trait"] tracing = ["dep:tracing"] watchdog = ["dep:parking_lot"] [dependencies] -async-trait = { version = "0.1.82", optional = true } +async-trait = { version = "0.1.83", optional = true } parking_lot = { version = "0.12.3", optional = true } tokio = { version = "1.40.0", features = ["rt"], optional = true } tracing = { version = "0.1.40", optional = true } ump = { version = "0.13.0" } @@ -35,5 +35,11 @@ [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] +[lints.clippy] +all = { level = "deny", priority = -1 } +pedantic = { level = "warn", priority = -1 } +nursery = { level = "warn", priority = -1 } +cargo = { level = "warn", priority = -1 } + Index: bacon.toml ================================================================== --- bacon.toml +++ bacon.toml @@ -7,11 +7,11 @@ # For information about clippy lints, see: # https://github.com/rust-lang/rust-clippy/blob/master/README.md #default_job = "check" -default_job = "clippy-all-pedantic" +default_job = "clippy-all" [jobs.check] command = ["cargo", "check", "--color", "always"] need_stdout = false @@ -21,10 +21,11 @@ # Run clippy on the default target [jobs.clippy] command = [ "cargo", "clippy", + "--all-features", "--color", "always", ] need_stdout = false # Run clippy on all targets @@ -41,37 +42,13 @@ # ] # need_stdout = false [jobs.clippy-all] command = [ "cargo", "clippy", - "--all-targets", - "--color", "always", -] -need_stdout = false - -[jobs.clippy-pedantic] -command = [ - "cargo", "clippy", - "--color", "always", - "--", - "-Wclippy::all", - "-Wclippy::pedantic", - "-Wclippy::nursery", - "-Wclippy::cargo" -] -need_stdout = false - -[jobs.clippy-all-pedantic] -command = [ - "cargo", "clippy", - "--all-targets", - "--color", "always", - "--", - "-Wclippy::all", - "-Wclippy::pedantic", - "-Wclippy::nursery", - "-Wclippy::cargo" + "--all-features", + "--all-targets", + "--color", "always", ] need_stdout = false # This job lets you run # - all tests: bacon test Index: src/lib.rs ================================================================== --- src/lib.rs +++ src/lib.rs @@ -44,10 +44,23 @@ //! If the dispatch loop should terminate once all the application's client //! end-points have been dropped, then the handler can store a [`WeakClient`] //! instead (as storing a cloned [`Client`] object will preventing the dispatch //! loop from terminating due to all clients being lost). The examples in the //! [`task`] and [`thread`] modules illustrate how to do this. +//! +//! ## Generics +//! When a new handler is created, it needs to define the generic type +//! parameters: +//! +//! - `S` - sent from the client to the server handler when making requests. +//! - `R` - replies sent back to the client from the server handler using. +//! [`ReplyContext::reply()`]. +//! - `E` - errors returned from server handler to requestor through +//! [`ReplyContext::fail()`] (and also returned by the server handler +//! construction closure). +//! - `RV` - return type the server handler can use to pass termination data +//! back to the dispatch loop creator once it terminates. #![cfg_attr(docsrs, feature(doc_cfg))] #[cfg(feature = "watchdog")] mod wdog; Index: src/task.rs ================================================================== --- src/task.rs +++ src/task.rs @@ -65,10 +65,13 @@ use async_trait::async_trait; use super::{channel, Client, ReplyContext}; /// Message processing trait for an async handler. +/// +/// See top module documentation for more information about [application +/// message handlers](crate#application-message-handlers). #[async_trait] pub trait Handler { /// Optional initialization callback. /// /// This is called on the dispatcher task before the main message dispatch @@ -107,13 +110,16 @@ } } /// Run a task which will process incoming messages from an ump server /// end-point. +/// +/// `hbldr` is a closure that should spawn a [`Handler`]. /// /// See top module's documentation for an overview of the [dispatch -/// loop](crate#dispatch-loop). +/// loop](crate#dispatch-loop) and what the [generic +/// parameters](crate#generics) are for. /// /// # Errors /// An application-defined error `E` is returned if the dispatch loop is /// terminated by a handler returning `ControlFlow::Break(E)`. #[allow(clippy::type_complexity)] Index: src/thread.rs ================================================================== --- src/thread.rs +++ src/thread.rs @@ -57,10 +57,13 @@ use std::{ops::ControlFlow, thread}; use super::{channel, Client, ReplyContext}; /// Message processing trait for a threaded handler. +/// +/// See top module documentation for more information about [application +/// message handlers](crate#application-message-handlers). pub trait Handler { /// Optional initialization callback. /// /// This is called on the dispatcher thread before the main message /// dispatch loop is entered. @@ -98,13 +101,16 @@ } } /// Run a thread which will process incoming messages from an ump server /// end-point. +/// +/// `hbldr` is a closure that should spawn a [`Handler`]. /// /// See top module's documentation for an overview of the [dispatch -/// loop](crate#dispatch-loop). +/// loop](crate#dispatch-loop) and what the [generic +/// parameters](crate#generics) are for. /// /// # Errors /// An application-defined error `E` is returned if the dispatch loop is /// terminated by a handler returning `ControlFlow::Break(E)`. #[allow(clippy::type_complexity)]