From 0fc91164e7bcad29244d2aa8427bbb1838e5794d Mon Sep 17 00:00:00 2001 From: Josh Robson Chase Date: Thu, 26 Oct 2023 16:06:19 -0400 Subject: [PATCH] ngrok: add Error impls for common pointer types --- ngrok/src/internals/proto.rs | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/ngrok/src/internals/proto.rs b/ngrok/src/internals/proto.rs index 04a1b77..4f2e6e1 100644 --- a/ngrok/src/internals/proto.rs +++ b/ngrok/src/internals/proto.rs @@ -9,6 +9,7 @@ use std::{ }, str::FromStr, string::FromUtf8Error, + sync::Arc, }; use muxado::typed::StreamType; @@ -54,6 +55,42 @@ pub trait Error: error::Error { } } +impl Error for Box +where + E: Error, +{ + fn error_code(&self) -> Option<&str> { + ::error_code(self) + } + fn msg(&self) -> String { + ::msg(self) + } +} + +impl Error for Arc +where + E: Error, +{ + fn error_code(&self) -> Option<&str> { + ::error_code(self) + } + fn msg(&self) -> String { + ::msg(self) + } +} + +impl<'a, E> Error for &'a E +where + E: Error, +{ + fn error_code(&self) -> Option<&str> { + ::error_code(self) + } + fn msg(&self) -> String { + ::msg(self) + } +} + #[derive(Serialize, Deserialize, Debug, Clone, Default)] pub struct ErrResp { pub msg: String,