Trait winsafe::prelude::shell_IShellItemArray

source ·
pub trait shell_IShellItemArray: ole_IUnknown {
    // Provided methods
    fn iter(&self) -> HrResult<impl Iterator<Item = HrResult<IShellItem>> + '_> { ... }
    fn GetCount(&self) -> HrResult<u32> { ... }
    fn GetItemAt(&self, index: u32) -> HrResult<IShellItem> { ... }
}
Available on crate features kernel and shell only.
Expand description

This trait is enabled with the shell feature, and provides methods for IShellItemArray.

Prefer importing this trait through the prelude:

use winsafe::prelude::*;

Provided Methods§

source

fn iter(&self) -> HrResult<impl Iterator<Item = HrResult<IShellItem>> + '_>

Returns an iterator over the IShellItem elements by calling IShellItemArray::GetCount and IShellItemArray::GetItemAt consecutively.

§Examples

Iterating over the IShellItem objects:

use winsafe::{self as w, prelude::*, co};

let ish_arr: w::IShellItemArray; // initialized somewhere

for ish_item in ish_arr.iter()? {
    let ish_item = ish_item?;
    println!("Path: {}",
        ish_item.GetDisplayName(co::SIGDN::FILESYSPATH)?);
}

Collecting the file paths into a Vec:

use winsafe::{self as w, prelude::*, co};

let ish_arr: w::IShellItemArray; // initialized somewhere

let paths = ish_arr.iter()?
    .map(|shi| {
        let shi = shi?;
        let name = shi.GetDisplayName(co::SIGDN::FILESYSPATH)?;
        Ok(name)
    })
    .collect::<w::HrResult<Vec<_>>>()?;
source

fn GetCount(&self) -> HrResult<u32>

source

fn GetItemAt(&self, index: u32) -> HrResult<IShellItem>

Object Safety§

This trait is not object safe.

Implementors§