setwallpaper/
lib.rs

1//! This module provides functionality to manage system wallpapers.
2//!
3//! You can use the functions in this module to set wallpapers on different platforms.#[cfg(target_family = "unix")]
4pub mod unix;
5
6#[cfg(target_family = "windows")]
7pub mod windows;
8
9/// This function sets the wallpaper from the given file path.
10///
11/// # Arguments
12///
13/// * `file_path` - A string slice that holds the file path of the wallpaper.
14///
15/// # Example
16///
17/// ```
18/// let result = set_wallpaper("/path/to/wallpaper.png");
19/// assert!(result.is_ok());
20/// ```
21pub fn from_file(filepath: &str) -> Result<(), std::io::Error> {
22    #[cfg(target_family = "unix")]
23    unix::set_wallpaper(filepath)?;
24
25    #[cfg(target_family = "windows")]
26    windows::set_wallpaper(filepath)?;
27    Ok(())
28}