Index: Cargo.toml ================================================================== --- Cargo.toml +++ Cargo.toml @@ -11,10 +11,11 @@ exclude = [ ".fossil-settings", ".efiles", ".fslckout", "www", + "bacon.toml", "rustfmt.toml" ] [features] default = ["tokio"] @@ -21,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-ng = { version = "0.2.0" } @@ -34,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 @@ -45,10 +45,25 @@ //! 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: +//! +//! - `P` - sent from the client to the server handler for uni-directional +//! messages. +//! - `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 @@ -78,10 +78,13 @@ use async_trait::async_trait; use super::{channel, Client, MsgType, 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 @@ -116,13 +119,17 @@ } } /// Launch a task that will process incoming messages from an ump-ng server /// end-point. +/// +/// `hbldr` is a closure that is expected to return the handler object that +/// will be responsible for processing received messages. /// /// 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 @@ -70,10 +70,13 @@ }; use super::{channel, Client, MsgType, 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 /// processing loop is entered. @@ -103,13 +106,17 @@ } } /// Launch a thread that will process incoming messages from an ump-ng server /// end-point. +/// +/// `hbldr` is a closure that is expected to return the handler object that +/// will be responsible for processing received messages. /// /// 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)]