Skip to content

Commit

Permalink
Update custom thiserror build to PR 145 for automatic generic bounds …
Browse files Browse the repository at this point in the history
…derivation

Replaced `#[error(transparent)]` usages, as they are not yet
supported in automatic generic constraint derivation.

Removed generic bounds from `TunnelRegistrationError` and
`TunnelNamingError` as they are conventionally incorrect and
made unnecessary with the new bound-generation capability.

See `thiserror` PR dtolnay/thiserror#145
  • Loading branch information
Dessix committed Sep 4, 2021
1 parent 1b0ec41 commit 5d850e6
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 38 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions NOTICE.md
Expand Up @@ -82,9 +82,9 @@ their own copyright notices and license terms:
* [strsim v0.8.0](https://github.com/dguo/strsim-rs) - MIT
* [syn v1.0.75](https://github.com/dtolnay/syn) - MIT OR Apache-2.0
* [textwrap v0.11.0](https://github.com/mgeisler/textwrap) - MIT
* [thiserror-impl v1.0.26](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror-impl v1.0.26 (proc-macro) (https://github.com/Dessix/thiserror?rev=02012b03f07bd7e06380fd2f13ea6a37ce4dfcc0#02012b03)](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror v1.0.26](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror-impl v1.0.28](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror-impl v1.0.28 (proc-macro) (https://github.com/Dessix/thiserror?rev=377de4811778b1e59cdfd242f8387dee10a3c1cb#377de481)](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror v1.0.28](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thread_local v1.1.3](https://github.com/Amanieu/thread_local-rs) - Apache-2.0/MIT
* [tinyvec_macros v0.1.0](https://github.com/Soveu/tinyvec_macros) - MIT OR Apache-2.0 OR Zlib
* [tinyvec v1.3.1](https://github.com/Lokathor/tinyvec) - Zlib OR Apache-2.0 OR MIT
Expand Down
2 changes: 1 addition & 1 deletion snocat-cli/Cargo.toml
Expand Up @@ -20,7 +20,7 @@ gen-z = "~0.1.0"
log = "~0.4.13"
quinn = "~0.7.2"
rcgen = "0.8"
thiserror = { version = "^1.0.26", git = "https://github.com/Dessix/thiserror", rev = "02012b03f07bd7e06380fd2f13ea6a37ce4dfcc0" }
thiserror = { version = "^1.0.28", git = "https://github.com/Dessix/thiserror", rev = "377de4811778b1e59cdfd242f8387dee10a3c1cb" }
tracing = "~0.1.22"
tracing-futures = "~0.2.4"
tracing-subscriber = "~0.2.20"
Expand Down
6 changes: 3 additions & 3 deletions snocat-cli/NOTICE.md
Expand Up @@ -81,9 +81,9 @@ their own copyright notices and license terms:
* [strsim v0.8.0](https://github.com/dguo/strsim-rs) - MIT
* [syn v1.0.75](https://github.com/dtolnay/syn) - MIT OR Apache-2.0
* [textwrap v0.11.0](https://github.com/mgeisler/textwrap) - MIT
* [thiserror-impl v1.0.26](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror-impl v1.0.26 (proc-macro) (https://github.com/Dessix/thiserror?rev=02012b03f07bd7e06380fd2f13ea6a37ce4dfcc0#02012b03)](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror v1.0.26](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror-impl v1.0.28](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror-impl v1.0.28 (proc-macro) (https://github.com/Dessix/thiserror?rev=377de4811778b1e59cdfd242f8387dee10a3c1cb#377de481)](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror v1.0.28](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thread_local v1.1.3](https://github.com/Amanieu/thread_local-rs) - Apache-2.0/MIT
* [tinyvec_macros v0.1.0](https://github.com/Soveu/tinyvec_macros) - MIT OR Apache-2.0 OR Zlib
* [tinyvec v1.3.1](https://github.com/Lokathor/tinyvec) - Zlib OR Apache-2.0 OR MIT
Expand Down
2 changes: 1 addition & 1 deletion snocat/Cargo.toml
Expand Up @@ -20,7 +20,7 @@ log = "~0.4.13"
quinn = "~0.7.2"
serde = { version = "~1.0.128", features=["derive"] }
serde_json = "~1.0.66"
thiserror = { version = "^1.0.26", git = "https://github.com/Dessix/thiserror", rev = "02012b03f07bd7e06380fd2f13ea6a37ce4dfcc0" }
thiserror = { version = "^1.0.28", git = "https://github.com/Dessix/thiserror", rev = "377de4811778b1e59cdfd242f8387dee10a3c1cb" }
tracing = "~0.1.22"
tracing-futures = "~0.2.4"
tracing-subscriber = "~0.2.20"
Expand Down
6 changes: 3 additions & 3 deletions snocat/NOTICE.md
Expand Up @@ -73,9 +73,9 @@ their own copyright notices and license terms:
* [socket2 v0.3.19](https://github.com/alexcrichton/socket2-rs) - MIT/Apache-2.0
* [spin v0.5.2](https://github.com/mvdnes/spin-rs.git) - MIT
* [syn v1.0.75](https://github.com/dtolnay/syn) - MIT OR Apache-2.0
* [thiserror-impl v1.0.26](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror-impl v1.0.26 (proc-macro) (https://github.com/Dessix/thiserror?rev=02012b03f07bd7e06380fd2f13ea6a37ce4dfcc0#02012b03)](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror v1.0.26](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror-impl v1.0.28](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror-impl v1.0.28 (proc-macro) (https://github.com/Dessix/thiserror?rev=377de4811778b1e59cdfd242f8387dee10a3c1cb#377de481)](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thiserror v1.0.28](https://github.com/dtolnay/thiserror) - MIT OR Apache-2.0
* [thread_local v1.1.3](https://github.com/Amanieu/thread_local-rs) - Apache-2.0/MIT
* [tinyvec_macros v0.1.0](https://github.com/Soveu/tinyvec_macros) - MIT OR Apache-2.0 OR Zlib
* [tinyvec v1.3.1](https://github.com/Lokathor/tinyvec) - Zlib OR Apache-2.0 OR MIT
Expand Down
9 changes: 3 additions & 6 deletions snocat/src/common/daemon/mod.rs
Expand Up @@ -222,15 +222,12 @@ where
}

#[derive(thiserror::Error, Debug)]
enum TunnelLifecycleError<
ApplicationError: std::fmt::Debug + std::fmt::Display + 'static,
RegistryError: std::fmt::Debug + std::fmt::Display + 'static,
> {
enum TunnelLifecycleError<ApplicationError, RegistryError> {
#[error("Tunnel registration error")]
RegistrationError(#[from] TunnelRegistrationError<RegistryError>),
#[error("Tunnel naming error")]
RegistryNamingError(#[from] TunnelNamingError<RegistryError>),
#[error(transparent)]
#[error("{0}")]
RequestProcessingError(RequestProcessingError<ApplicationError>),
#[error("Authentication refused to remote by either breach of protocol or invalid/inadequate credentials")]
AuthenticationRefused,
Expand All @@ -239,7 +236,7 @@ enum TunnelLifecycleError<
}

#[derive(thiserror::Error, Debug)]
enum RequestProcessingError<ApplicationError: std::fmt::Debug + std::fmt::Display> {
enum RequestProcessingError<ApplicationError> {
#[error("Protocol version mismatch")]
UnsupportedProtocolVersion,
#[error("Tunnel error encountered: {0}")]
Expand Down
1 change: 0 additions & 1 deletion snocat/src/common/protocol/negotiation.rs
Expand Up @@ -21,7 +21,6 @@ use super::{
pub const SNOCAT_NEGOTIATION_MAGIC: &[u8; 4] = &[0x4e, 0x59, 0x41, 0x4e]; // UTF-8 "NYAN"

#[derive(thiserror::Error, Debug)]
#[error(bound = std::fmt::Debug)]
pub enum NegotiationError<ApplicationError> {
#[error("Stream read failed")]
ReadError,
Expand Down
4 changes: 1 addition & 3 deletions snocat/src/common/protocol/service/mod.rs
Expand Up @@ -15,7 +15,6 @@ use super::{negotiation::NegotiationError, RouteAddress};
// Client

#[derive(thiserror::Error, Debug)]
#[error(bound = std::fmt::Debug)]
pub enum ClientError<ApplicationError> {
#[error("Invalid address provided to client")]
InvalidAddress,
Expand Down Expand Up @@ -396,7 +395,6 @@ impl<'client, TStream, TClient> Request<'client, TStream, TClient> {
}

#[derive(thiserror::Error, Debug)]
#[error(bound = std::fmt::Debug)]
pub enum RoutingError<RouterError> {
#[error("Route not found for request")]
RouteNotFound(RouteAddress),
Expand All @@ -406,7 +404,7 @@ pub enum RoutingError<RouterError> {
InvalidAddress,
#[error("The tunnel failed to provide a link")]
LinkOpenFailure(#[from] super::tunnel::TunnelError),
#[error(transparent)]
#[error("{0}")]
NegotiationError(NegotiationError<RouterError>),
#[error("Routing error: {0:?}")]
RouterError(RouterError),
Expand Down
1 change: 0 additions & 1 deletion snocat/src/common/protocol/traits.rs
Expand Up @@ -21,7 +21,6 @@ use super::{
use crate::common::protocol::tunnel::TunnelError;

#[derive(thiserror::Error, Debug)]
#[error(bound = std::fmt::Debug)]
pub enum ServiceError<InternalError> {
#[error("Address refused by client")]
Refused,
Expand Down
4 changes: 2 additions & 2 deletions snocat/src/common/protocol/tunnel/registry/mod.rs
Expand Up @@ -71,7 +71,7 @@ impl<TTunnel: ?Sized, TMetadata> Debug for TunnelRecord<TTunnel, TMetadata> {
}

#[derive(thiserror::Error, Debug)]
pub enum TunnelRegistrationError<ApplicationError: Debug + Display> {
pub enum TunnelRegistrationError<ApplicationError> {
#[error("Tunnel ID was already occupied")]
IdOccupied(TunnelId),
#[error("Application error in tunnel registration")]
Expand All @@ -87,7 +87,7 @@ impl<ApplicationError: Debug + Display> From<ApplicationError>
}

#[derive(thiserror::Error, Debug)]
pub enum TunnelNamingError<ApplicationError: Debug + Display> {
pub enum TunnelNamingError<ApplicationError> {
#[error("The tunnel to be named was not found")]
TunnelNotRegistered(TunnelId),
#[error("Application error in tunnel naming")]
Expand Down

0 comments on commit 5d850e6

Please sign in to comment.