Index: Cargo.toml ================================================================== --- Cargo.toml +++ Cargo.toml @@ -1,8 +1,8 @@ [package] name = "umpx" -version = "0.0.1" +version = "0.0.2" edition = "2021" license = "0BSD" # https://crates.io/category_slugs categories = [ "concurrency", "asynchronous" ] keywords = [ "ump", "message-passing" ] @@ -12,10 +12,11 @@ exclude = [ ".fossil-settings", ".efiles", ".fslckout", "www", + "bacon.toml", "rustfmt.toml" ] # https://doc.rust-lang.org/cargo/reference/manifest.html#the-badges-section [badges] @@ -24,14 +25,14 @@ [features] sqlsrv = ["dep:sqlsrv", "sqlsrv/tpool", "dep:threadpool"] [dependencies] sqlsrv = { version = "0.5.0", optional = true } -swctx = { version = "0.2.2" } +swctx = { version = "0.3.0" } threadpool = { version = "1.8.1", optional = true } -ump = { version = "0.12.1" } -ump-server = { version = "0.3.0" } +ump = { version = "0.13.0" } +ump-server = { version = "0.4.0" } [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] ADDED bacon.toml Index: bacon.toml ================================================================== --- /dev/null +++ bacon.toml @@ -0,0 +1,130 @@ +# This is a configuration file for the bacon tool +# +# Bacon repository: https://github.com/Canop/bacon +# Complete help on configuration: https://dystroy.org/bacon/config/ +# You can also check bacon's own bacon.toml file +# as an example: https://github.com/Canop/bacon/blob/main/bacon.toml + +# 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" + +[jobs.check] +command = ["cargo", "check", "--color", "always"] +need_stdout = false + +[jobs.check-all] +command = ["cargo", "check", "--all-targets", "--color", "always"] +need_stdout = false + +# Run clippy on the default target +[jobs.clippy] +command = [ + "cargo", "clippy", + "--color", "always", +] +need_stdout = false + +# Run clippy on all targets +# To disable some lints, you may change the job this way: +# [jobs.clippy-all] +# command = [ +# "cargo", "clippy", +# "--all-targets", +# "--color", "always", +# "--", +# "-A", "clippy::bool_to_int_with_if", +# "-A", "clippy::collapsible_if", +# "-A", "clippy::derive_partial_eq_without_eq", +# ] +# 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" +] +need_stdout = false + +# This job lets you run +# - all tests: bacon test +# - a specific test: bacon test -- config::test_default_files +# - the tests of a package: bacon test -- -- -p config +[jobs.test] +command = [ + "cargo", "test", "--color", "always", + "--", "--color", "always", # see https://github.com/Canop/bacon/issues/124 +] +need_stdout = true + +[jobs.doc] +command = ["cargo", "doc", "--color", "always", "--no-deps"] +need_stdout = false + +# If the doc compiles, then it opens in your browser and bacon switches +# to the previous job +[jobs.doc-open] +command = ["cargo", "doc", "--color", "always", "--no-deps", "--open"] +need_stdout = false +on_success = "back" # so that we don't open the browser at each change + +# You can run your application and have the result displayed in bacon, +# *if* it makes sense for this crate. +# Don't forget the `--color always` part or the errors won't be +# properly parsed. +# If your program never stops (eg a server), you may set `background` +# to false to have the cargo run output immediately displayed instead +# of waiting for program's end. +[jobs.run] +command = [ + "cargo", "run", + "--color", "always", + # put launch parameters for your program behind a `--` separator +] +need_stdout = true +allow_warnings = true +background = true + +# This parameterized job runs the example of your choice, as soon +# as the code compiles. +# Call it as +# bacon ex -- my-example +[jobs.ex] +command = ["cargo", "run", "--color", "always", "--example"] +need_stdout = true +allow_warnings = true + +# You may define here keybindings that would be specific to +# a project, for example a shortcut to launch a specific job. +# Shortcuts to internal functions (scrolling, toggling, etc.) +# should go in your personal global prefs.toml file instead. +[keybindings] +# alt-m = "job:my-job" +c = "job:clippy-all" # comment this to have 'c' run clippy on only the default target Index: src/server/sqlsrv/utils.rs ================================================================== --- src/server/sqlsrv/utils.rs +++ src/server/sqlsrv/utils.rs @@ -1,9 +1,7 @@ //! Integration utilities for creating sqlsrv handlers. -use std::fmt; - use super::{ r2d2, rusqlite::{params, Connection}, ConnPool, WrConn }; @@ -25,23 +23,20 @@ rctx: ReplyContext, f: F ) -> Result<(), r2d2::Error> where R: Send + 'static, - E: fmt::Debug + Send + 'static, + E: std::error::Error + Send + 'static, F: FnOnce(&Connection) -> Result + Send + 'static { let roconn = cpool.reader()?; let res = match f(&roconn) { Ok(reply) => rctx.reply(reply), Err(e) => rctx.fail(e) }; if let Err(e) = res { - // Note: This can currently not happen. - // Leave a printout here as a reminder in case that changes in the - // future. eprintln!("Reply message pass failed; {}", e); } Ok(()) } @@ -58,11 +53,11 @@ rctx: ReplyContext, f: F ) -> Result<(), r2d2::Error> where R: Send + 'static, - E: fmt::Debug + Send + 'static, + E: std::error::Error + Send + 'static, F: FnOnce(&Connection) -> Result + Send + 'static { let roconn = cpool.reader()?; tpool.execute(move || { @@ -69,13 +64,10 @@ let res = match f(&roconn) { Ok(reply) => rctx.reply(reply), Err(e) => rctx.fail(e) }; if let Err(e) = res { - // Note: This can currently not happen. - // Leave a printout here as a reminder in case that changes in the - // future. eprintln!("Reply message pass failed; {}", e); } }); Ok(()) @@ -88,23 +80,20 @@ /// Translates the closure's `Result` into a `ReplyContext::reply()` on /// `Ok` and `ReplyContext::fail()` on `Err`. pub fn proc_rwdb_req(cpool: &ConnPool, rctx: ReplyContext, f: F) where R: Send + 'static, - E: fmt::Debug + Send + 'static, + E: std::error::Error + Send + 'static, F: FnOnce(&mut WrConn) -> Result + Send + 'static { let mut rwconn = cpool.writer(); let res = match f(&mut rwconn) { Ok(reply) => rctx.reply(reply), Err(e) => rctx.fail(e) }; if let Err(e) = res { - // Note: This can currently not happen - // Leave a printout here as a reminder in case that changes in the - // future. eprintln!("Reply message pass failed; {}", e); } } @@ -118,11 +107,11 @@ tpool: &ThreadPool, rctx: ReplyContext, f: F ) where R: Send + 'static, - E: fmt::Debug + Send + 'static, + E: std::error::Error + Send + 'static, F: FnOnce(&mut WrConn) -> Result + Send + 'static { let mut rwconn = cpool.writer(); tpool.execute(move || { @@ -129,13 +118,10 @@ let res = match f(&mut rwconn) { Ok(reply) => rctx.reply(reply), Err(e) => rctx.fail(e) }; if let Err(e) = res { - // Note: This can currently not happen - // Leave a printout here as a reminder in case that changes in the - // future. eprintln!("Reply message pass failed; {}", e); } }); } @@ -142,10 +128,11 @@ /// Perform an incremental vacuum. /// /// `n` is the number of freelist nodes to reclaim. If `None` all nodes will /// be reclaimed. +#[must_use] pub fn incremental_vacuum( cpool: &ConnPool, tpool: &ThreadPool, n: Option ) -> swctx::WaitCtx<(), (), rusqlite::Error> { @@ -152,20 +139,24 @@ let (sctx, wctx) = swctx::mkpair(); let conn = cpool.writer(); tpool.execute(move || { + #[allow(clippy::option_if_let_else)] let res = if let Some(n) = n { conn.execute("PRAGMA incremental_vacuum(?);", params![n]) } else { conn.execute("PRAGMA incremental_vacuum;", params![]) }; - match res { + let res = match res { Ok(_) => sctx.set(()), Err(e) => sctx.fail(e) + }; + if let Err(e) = res { + eprintln!("Reply message pass failed; {}", e); } }); wctx } // vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :