Issue with rustube 0.6.0: Missing Callback Struct despite Documentation

I am having trouble with the rustube crate version 0.6.0 and its callback struct. The official documentation suggests that the callback struct should be available, but when I use it, I'm getting an error saying 'no callback struct in rustube.'
When I write use rustube::Callback , I get error :

error[E0432]: unresolved import `rustube::Callback`
  --> src\assets.rs:15:5
   |
15 |     Callback
   |     ^^^^^^^^ no `Callback` in the root

e `&Stream` in the current scope
  --> src\assets.rs:43:24
   |
43 | ...        stream.download_to_dir_with_callback(VIDEOS_DIR,callback).aw... 
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: there is a method with a similar name: `download_to_dir`

I've checked my Cargo.toml configuration and confirmed the crate version(as below).

[package]
name = "reddit-motion"
version = "0.1.0"
edition = "2021"

[dependencies]
# For progress bar
indicatif = "0.17.6"

# For downloading neccessary youtube videos
rustube = "0.6.0"

And this is the relevent code

//...
use rustube::{
    tokio::{
        spawn,
        join
    },
    Video,
    Id,
};

pub(in crate) async fn download_background_videos() {
       //....
           let _id = Id::from_str(id).unwrap();
                let _video = Video::from_id(_id.into_owned()).await.unwrap();
                let stream = _video.best_video().unwrap();

                let callback = Callback::new().connect_on_complete_closure(|_| 
                  progress_bar.inc(1) );

                stream.download_to_dir_with_callback(VIDEOS_DIR,callback).await;
    //...
}

Is anyone else facing this issue or am I missing something? Any help or insights would be greatly appreciated!"

You need to enable the callback feature.

rustube = { version = "0.6.0", features = ["callback"] }

When an item that should be present is missing, always check if the crate has optional features. (This one unfortunately doesn't mention the feature in the docs for Callback itself.)

2 Likes