Skip to main content

load_custom_icon

Function load_custom_icon 

Source
pub fn load_custom_icon(
    provider: &(impl IconProvider + ?Sized),
    icon_set: &str,
) -> Option<IconData>
Expand description

Load an icon from any IconProvider, dispatching through the standard platform loading chain.

§Fallback chain

  1. Provider’s icon_name() – passed to platform system loader via load_system_icon_by_name()
  2. Provider’s icon_svg() – bundled SVG data
  3. Noneno cross-set fallback (mixing icon sets is forbidden)

The icon_set string is parsed via IconSet::from_name(), falling back to system_icon_set() for unrecognized names.

§Examples

use native_theme::{load_custom_icon, IconRole};

// IconRole implements IconProvider, so it works with load_custom_icon
let icon = load_custom_icon(&IconRole::ActionCopy, "material");
assert!(icon.is_some());