Index: Cargo.toml ================================================================== --- Cargo.toml +++ Cargo.toml @@ -1,8 +1,8 @@ [package] name = "ump-ngx" -version = "0.0.1" +version = "0.0.2" edition = "2021" license = "0BSD" # https://crates.io/category_slugs categories = [ "concurrency", "asynchronous" ] keywords = [ "ump-ng", "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] @@ -25,14 +26,14 @@ #tokio = ["ump-ng-server/tokio"] 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-ng = { version = "0.1.0" } -ump-ng-server = { version = "0.3.0" } +ump-ng = { version = "0.2.0" } +ump-ng-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 ADDED rustfmt.toml Index: rustfmt.toml ================================================================== --- /dev/null +++ rustfmt.toml @@ -0,0 +1,14 @@ +blank_lines_upper_bound = 2 +comment_width = 79 +edition = "2021" +format_strings = true +max_width = 79 +match_block_trailing_comma = false +# merge_imports = true +newline_style = "Unix" +tab_spaces = 2 +trailing_comma = "Never" +unstable_features = true +wrap_comments = true +#reorder_imports = false +#reorder_modules = false 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, ConnPool, WrConn}; use rusqlite::Connection; use threadpool::ThreadPool; @@ -13,30 +11,28 @@ pub enum Error { R2D2(r2d2::Error), App(E) } - /// Process a requested read-only database operation message. pub fn proc_rodb_req( cpool: &ConnPool, 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 eprintln!("Reply message pass failed; {}", e); } Ok(()) } @@ -55,11 +51,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 || { @@ -66,38 +62,34 @@ 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 eprintln!("Reply message pass failed; {}", e); } }); Ok(()) } - /// Process a requested read/write database message. 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 conn = cpool.writer(); let res = match f(&mut conn) { Ok(reply) => rctx.reply(reply), Err(e) => rctx.fail(e) }; if let Err(e) = res { - // Note: This can currently not happen eprintln!("Reply message pass failed; {}", e); } } - /// Process a requested read/write database message on a thread pool. /// /// The read/write database connection will be acquired from the connection /// pool `cpool`. The tread will be launched on the thread pool `tpool`. @@ -110,11 +102,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 || { @@ -121,12 +113,11 @@ 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 eprintln!("Reply message pass failed; {}", e); } }); } // vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :