Skip to main content

ShellItem

Trait ShellItem 

Source
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§

Source

fn get_display_name(&self, name: ShellItemDisplayName) -> Result<U16CString>

Source

fn compare(&self, psi: &IShellItem, flags: u32) -> Result<Ordering>

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.

Source

fn get_attributes(&self, mask: ItemAttributes) -> Result<ItemAttributes>

Provided Methods§

Source

fn from_path_w(path: PCWSTR) -> Result<IShellItem>

SHCreateItemFromParsingName function (shobjidl_core.h)

Although not documented, this requires CoInitialize().

Source

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

Source

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".

Implementors§