Skip to content

Commit b4c22b0

Browse files
committed
Result type
1 parent bdbcee0 commit b4c22b0

File tree

1 file changed

+6
-3
lines changed
  • crates/stackable-webhook/src

1 file changed

+6
-3
lines changed

crates/stackable-webhook/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ pub trait WebhookHandler<Req, Res> {
5656
fn call(self, req: Req) -> Res;
5757
}
5858

59+
/// A result type alias with the library-level [`Error`] type as the default error type.
60+
pub type Result<T, E = WebhookError> = std::result::Result<T, E>;
61+
5962
#[derive(Debug, Snafu)]
6063
pub enum WebhookError {
6164
#[snafu(display("failed to create TLS server"))]
@@ -120,7 +123,7 @@ impl WebhookServer {
120123
router: Router,
121124
options: Options,
122125
subject_alterative_dns_names: Vec<String>,
123-
) -> Result<(Self, mpsc::Receiver<Certificate>), WebhookError> {
126+
) -> Result<(Self, mpsc::Receiver<Certificate>)> {
124127
tracing::trace!("create new webhook server");
125128

126129
// TODO (@Techassi): Make opt-in configurable from the outside
@@ -154,7 +157,7 @@ impl WebhookServer {
154157
/// Runs the Webhook server and sets up signal handlers for shutting down.
155158
///
156159
/// This does not implement graceful shutdown of the underlying server.
157-
pub async fn run(self) -> Result<(), WebhookError> {
160+
pub async fn run(self) -> Result<()> {
158161
let future_server = self.run_server();
159162
let future_signal = async {
160163
let mut sigint = signal(SignalKind::interrupt()).expect("create SIGINT listener");
@@ -187,7 +190,7 @@ impl WebhookServer {
187190

188191
/// Runs the webhook server by creating a TCP listener and binding it to
189192
/// the specified socket address.
190-
async fn run_server(self) -> Result<(), WebhookError> {
193+
async fn run_server(self) -> Result<()> {
191194
tracing::debug!("run webhook server");
192195

193196
self.tls_server.run().await.context(RunTlsServerSnafu)

0 commit comments

Comments
 (0)