qsu

Check-in Differences
Login

Check-in Differences

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Difference From qsu-0.1.0 To qsu-0.2.0

2024-01-16
16:35
Re-export apperr. check-in: c571a6d179 user: jan tags: qsu-0.2.1, trunk
16:23
Happy Clippy check-in: 9b8128a6c3 user: jan tags: qsu-0.2.0, trunk
16:16
Fix doctests. check-in: 83d06ba8bb user: jan tags: trunk
15:59
Crate maintenance: Update apperr to 0.2.0, and fix a bug that was uncovered by it. check-in: f22db69940 user: jan tags: trunk
2024-01-10
13:53
Documentation updates and prepare for 0.1.0. check-in: 54ae1190a4 user: jan tags: qsu-0.1.0, trunk
2023-12-13
13:06
Add missing comma. check-in: d9feea0cec user: jan tags: trunk

Changes to Cargo.toml.

1
2
3

4
5
6
7
8
9
10
1
2

3
4
5
6
7
8
9
10


-
+







[package]
name = "qsu"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
license = "0BSD"
categories = [ "asynchronous" ]
keywords = [ "service", "systemd", "winsvc" ]
repository = "https://repos.qrnch.tech/pub/qsu"
description = "Service subsystem wrapper."
rust-version = "1.56"
26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
26
27
28
29
30
31
32

33
34
35
36
37
38
39
40







-
+







systemd = ["dep:sd-notify"]
rocket = ["rt", "dep:rocket", "tokio"]
rt = []
tokio = ["rt", "tokio/macros", "tokio/rt-multi-thread", "tokio/signal"]
wait-for-debugger = ["dep:dbgtools-win"]

[dependencies]
apperr = { version = "0.1.0" }
apperr = { version = "0.2.0" }
async-trait = { version = "0.1.77" }
chrono = { version = "0.4.31" }
clap = { version = "4.4.14", optional = true, features = [
  "derive", "env", "string", "wrap_help"
] }
env_logger = { version = "0.10.1" }
futures = { version = "0.3.30" }

Changes to examples/err/mod.rs.

1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17









+







use std::{fmt, io};

#[derive(Debug)]
pub enum Error {
  IO(String),
  Qsu(String)
}

impl std::error::Error for Error {}
impl apperr::Blessed for Error {}

impl fmt::Display for Error {
  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
    match self {
      Error::IO(s) => {
        write!(f, "I/O error; {}", s)
      }

Changes to src/err.rs.

79
80
81
82
83
84
85
86




87
88
89
90

91
92
93
94
95
96
97
98
99
100




101
102
103
104
105
106
107
79
80
81
82
83
84
85

86
87
88
89
90
91
92

93
94
95
96
97
98
99
100
101
102

103
104
105
106
107
108
109
110
111
112
113







-
+
+
+
+



-
+









-
+
+
+
+







    matches!(self, Error::App(_))
  }

  /// Attempt to convert [`Error`] into application-specific error.
  ///
  /// If it's not an `Error::App()` nor can be downcast to type `E`, the error
  /// will be returned back as an `Err()`.
  pub fn try_into_apperr<E: 'static>(self) -> Result<E, Error> {
  pub fn try_into_apperr<E>(self) -> Result<E, Error>
  where
    E: std::error::Error + apperr::Blessed + 'static
  {
    match self {
      Error::App(e) => match e.try_into_inner::<E>() {
        Ok(e) => Ok(e),
        Err(e) => Err(Error::App(AppErr::new(e)))
        Err(e) => Err(Error::App(e))
      },
      e => Err(e)
    }
  }

  /// Unwrap application-specific error from an [`Error`].
  ///
  /// # Panic
  /// Panics if `Error` variant is not `Error::App()`.
  pub fn unwrap_apperr<E: 'static>(self) -> E {
  pub fn unwrap_apperr<E>(self) -> E
  where
    E: std::error::Error + apperr::Blessed + 'static
  {
    let Ok(e) = self.try_into_apperr::<E>() else {
      panic!("Unable to unwrap error E");
    };
    e
  }

  pub fn bad_format<S: ToString>(s: S) -> Self {

Changes to src/rt.rs.

72
73
74
75
76
77
78


79

80
81
82







83
84
85
86
87
88
89
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99







+
+

+



+
+
+
+
+
+
+







//!
//! Presumably the application has it's own `Error` type.  To allow the
//! callbacks to return application-defined errors using the regular question
//! mark, it may be helpful to add the following error conversion to the error
//! module:
//!
//! ```
//! use std::fmt;
//!
//! // Application-specific Error type
//! #[derive(Debug)]
//! enum Error {
//!   // .. application-defined error variants
//! }
//! impl fmt::Display for Error {
//!   fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
//!     Ok(())
//!   }
//! }
//! impl std::error::Error for Error {}
//! impl apperr::Blessed for Error {}
//!
//! impl From<Error> for qsu::AppErr {
//!   fn from(err: Error) -> qsu::AppErr {
//!     qsu::AppErr::new(err)
//!   }
//! }
//! ```

Changes to tests/err/mod.rs.

1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18










+







use std::{fmt, io};

#[derive(Debug)]
pub enum Error {
  Hello(String),
  IO(String),
  Qsu(String)
}

impl std::error::Error for Error {}
impl apperr::Blessed for Error {}

impl Error {
  pub fn hello(msg: impl ToString) -> Self {
    Error::Hello(msg.to_string())
  }
}

Changes to www/changelog.md.

1
2
3
4
5
6
7



8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17







+
+
+







# Change log

## [Unreleased]

### Added

### Changed

- Use apperr 0.2.0, which introduces trait bounds to the `AppErr::new(E)` to
  make it more difficult to pass the wrong type to it.

### Removed

---

## [0.1.0] - 2024-01-10