the method model exists for struct SelectionModel, but its trait bounds were not satisfied
And what is strange to me that when I check the gtk::SelectionModel, there I can find the model method. So I really don't understand why I cannot call it?
I'm sorry, there is some mistake on my part. Now that I tried to find that method in code so I could post screenshot I cannot find it.
OK, I got it, the method model is in SingleSelection type.
So, just to make sure that I understand what that compiler msg means. I understand it as the trait has not been defined for that type, is that correct?
The specific compiler error you ran in to can be pretty bad sometimes. It will occasionally say that the method exists but trait bounds were not satisfied even though the method really just doesn't exist at all for that type.
Thank you for the answer.
Here is another problem of the same type (last line, I've also pasted a screenshot to show that the set_file method indeed is there):
list_view.connect_activate(|col_view, inx| {
println!("ColumnViewClicked:{},{}", col_view, inx);
let ss_mod: gtk::SingleSelection = col_view
.model()
.unwrap()
.downcast::<gtk::SingleSelection>()
.unwrap();
let list_model: gio::ListModel = ss_mod.model();
let sm = list_model.downcast::<gtk::SortListModel>().unwrap();
<gtk::SortListModel as gtk::DirectoryList>::set_file(sm, "a");
});
I'm confused about the <gtk::SortListModel as gtk::DirectoryList> syntax here. This usually requires that the right-hand-side is a trait, but DirectoryList is a struct. As a quick check, this fails in a similar way:
struct A {}
struct B {}
impl B {
fn foo() {}
}
fn foo() {
<A as B>::foo();
}
You probably need to figure out how gtk wants you to do downcasting.
Hi and sorry for the late reply.
The point is that DirectoryList IS a ListModel.
The problem I'm having is that after getting the model (the ListModel) from:
let list_model: gio::ListModel = ss_mod.model();
But this^^^ model is in fact gtk::DirectoryList. The question is how to access that interface?