From 74e23036528f2b057125ae5b9ed3ef06e92c4869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Mon, 27 Dec 2021 01:12:16 +0100 Subject: [PATCH] Disconnect after getting URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7661715..cce9b8e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,7 +31,7 @@ async fn main() -> Result<(), Option<()>> { .build() .unwrap(); - while let Some(events) = client.wait_for_events().await { + 'outer: while let Some(events) = client.wait_for_events().await { for event in events { match event { Event::Online => { @@ -43,10 +43,11 @@ async fn main() -> Result<(), Option<()>> { } Event::HTTPUploadedFile(url) => { println!("URL: {}", url); + client.disconnect().await.unwrap(); }, Event::Disconnected => { println!("Disconnected"); - return Err(None); + break 'outer; } _ => (), }