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
lang-rust
querydoes not take any kind ofselfso you cannot use method syntax. Additionally, it takes a&Arc<Self>which is definitely a bit of a strange API.