Lonami / grammers

(tele)gramme.rs - use Telegram's API from Rust
https://t.me/gramme_rs
Apache License 2.0
554 stars 113 forks source link

Add check if media downloadable #219

Closed IMXEren closed 8 months ago

IMXEren commented 8 months ago

Aims to fix #216 . Tested with code:


// If there's a error, propagates it back to the caller.
let download = message.download_media(&path).await?;

// OR

if let Ok(to_download) = message.download_media(&path).await {
    if to_download {
        // Media was there to download
    }
}

// OR

let download = message.download_media(&path).await;
if download.is_ok() && download.unwrap() {
    // Media was there to download
}

I suppose that there is no need to change the description for client.download_media(). Users must implement error handling and not call .unwrap() directly.

Lonami commented 8 months ago

Thanks.