From 2874e6f98abad8448bda5c4229293f1eb857b76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Dybiec?= Date: Mon, 11 Nov 2024 22:56:20 +0000 Subject: Fix panic when closing --- src/mattermost/client.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/mattermost/client.rs') diff --git a/src/mattermost/client.rs b/src/mattermost/client.rs index 861e0a8..2172338 100644 --- a/src/mattermost/client.rs +++ b/src/mattermost/client.rs @@ -15,6 +15,11 @@ pub struct Client { bearer_token: Option, client: reqwest::Client, } +impl std::fmt::Debug for Client { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Client").field("url", &self.url).finish() + } +} #[async_trait::async_trait] pub trait Handler { @@ -26,10 +31,10 @@ pub trait Handler { } impl Client { - pub(crate) fn new(auth: AuthData, url: &str) -> Self { + pub(crate) fn new(auth: AuthData, url: String) -> Self { Self { auth, - url: url.to_owned(), + url, bearer_token: None, client: reqwest::Client::new(), } @@ -90,6 +95,7 @@ impl Client { match json { Ok(websocketmessage) => { if let WebsocketMessage::Update(update) = websocketmessage { + debug!("Handling update {:?}", update); if let Err(err) = handler.handle(update, &self).await { warn!("Handler returned error: {err}"); } -- cgit v1.2.3