pub trait ShellItem {
// Required methods
fn get_display_name(&self, name: ShellItemDisplayName) -> Result<U16CString>;
fn compare(&self, psi: &IShellItem, flags: u32) -> Result<Ordering>;
fn get_attributes(&self, mask: ItemAttributes) -> Result<ItemAttributes>;
// Provided methods
fn from_path_w(path: PCWSTR) -> Result<IShellItem> { ... }
fn from_id_list(id_list: &AbsoluteIDList) -> Result<IShellItem> { ... }
fn is_folder(&self) -> bool { ... }
}Expand description
Required Methods§
Sourcefn get_display_name(&self, name: ShellItemDisplayName) -> Result<U16CString>
fn get_display_name(&self, name: ShellItemDisplayName) -> Result<U16CString>
Sourcefn compare(&self, psi: &IShellItem, flags: u32) -> Result<Ordering>
fn compare(&self, psi: &IShellItem, flags: u32) -> Result<Ordering>
-
flags:SICHINTF_*(shobjidl_core.h)Different from
ShellFolder::compare_ids(), specifying the column doesn’t work. (Cleared by& 0xf0000000)
Internally, this usually calls ShellFolder::compare_ids().
IShellItem::Compare (shobjidl_core.h)
§Returns
Although the doc just says
“If the two items are the same this parameter equals zero; if they are different the parameter is nonzero.”
The sign actually defines the order like ShellFolder::compare_ids() does.
Provided Methods§
Sourcefn from_path_w(path: PCWSTR) -> Result<IShellItem>
fn from_path_w(path: PCWSTR) -> Result<IShellItem>
SHCreateItemFromParsingName function (shobjidl_core.h)
Although not documented, this requires CoInitialize().
Sourcefn from_id_list(id_list: &AbsoluteIDList) -> Result<IShellItem>
fn from_id_list(id_list: &AbsoluteIDList) -> Result<IShellItem>
SHCreateItemFromIDList function (shobjidl_core.h) - Win32 apps | Microsoft Learn
§References
https://github.com/Hau-Hau/restart-explorer/blob/230ed6dd78ac656a86e07310c3afc62f03057a36/src/infrastructure/windows_os/persist_id_list.rs
Sourcefn is_folder(&self) -> bool
fn is_folder(&self) -> bool
Tests if the item is a Shell folder (not necessarily a file system directory).
This can also be implemented via ShellItem::get_display_name().
But it’s probably slower as attributes are already stored in the ID list.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".