From 8573b75047f567fb2af77c867ff14a0cb99157c5 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Wed, 27 Nov 2024 19:09:10 +0400 Subject: [PATCH] style: replace common Result return type with alias --- src/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 70f2380..003ef54 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,8 @@ const POLL_TIMEOUT: &str = "300"; /// Update types to receive (filtered out on tg backend) const POLL_TYPES: &str = r#"["message"]"#; +type BotFnResult = Result<(), reqwest::Error>; + #[tokio::main] async fn main() -> std::io::Result<()> { let cfg = { @@ -63,7 +65,7 @@ async fn main() -> std::io::Result<()> { Ok(()) } -async fn init_cmds(client: &Client, token: &str) -> Result<(), reqwest::Error> { +async fn init_cmds(client: &Client, token: &str) -> BotFnResult { client .post(format!("{BOT_URL}{token}/setMyCommands")) .form(&[( @@ -83,7 +85,7 @@ async fn init_cmds(client: &Client, token: &str) -> Result<(), reqwest::Error> { Ok(()) } -async fn handler(cfg: &Config, s: &mut State) -> Result<(), reqwest::Error> { +async fn handler(cfg: &Config, s: &mut State) -> BotFnResult { let mut updates = cfg .client .get((*cfg.upd_url).clone()) @@ -148,7 +150,7 @@ async fn handler(cfg: &Config, s: &mut State) -> Result<(), reqwest::Error> { Ok(()) } -async fn send_comic(cfg: Config, ctx: SenderCtx) -> Result<(), reqwest::Error> { +async fn send_comic(cfg: Config, ctx: SenderCtx) -> BotFnResult { let info = cfg .client .get(ctx.url.clone())