0

I am trying to recursively iterate on directories using smb::resource::directory::Directory. I managed to initiate the tree connection, however I can't seem to access the query method.

Here are the methods I can access:

The method I use to have a tree variable is always dereferenced. I tried the as_dir, unwrap_dir and try_into methods.

Here is my code:

#[tokio::main]
async fn list_dir_recursive(tree: &Arc<smb::Tree>, path: &str) -> Result<(), Box<dyn std::error::Error>>{
 let resource = tree.open_existing(path, FileAccessMask::FILE_LIST_DIRECTORY).await?;
 let dir: smb::Directory = resource.try_into().unwrap();
 let entries = dir.query("*").await?; // this is what I would want to do
 for entry in entries {
 let name = entry.file_name();
 let full_path = if path.is_empty() {
 name.to_string()
 } else {
 format!("{}/{}", path, name)
 };
 println!("{}", full_path);
 if entry.is_directory() && name != "." && name != ".." {
 list_dir_recursive(tree, &full_path).await?;
 }
 }
 Ok(())
}
John Kugelman
365k70 gold badges555 silver badges600 bronze badges
asked Nov 7, 2025 at 22:15
1
  • query does not take any kind of self so you cannot use method syntax. Additionally, it takes a &Arc<Self> which is definitely a bit of a strange API. Commented Nov 8, 2025 at 3:22

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.