mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-26 03:36:32 +11:00
compile with icon_loading feature on docs.rs (#509)
* compile with icon_loading feature on docs.rs these functions should be more visible now. * Explicitly document which functions require icon_loading
This commit is contained in:
parent
741bcc4672
commit
b4a8c08f43
2 changed files with 13 additions and 0 deletions
|
@ -10,6 +10,9 @@ repository = "https://github.com/tomaka/winit"
|
||||||
documentation = "https://docs.rs/winit"
|
documentation = "https://docs.rs/winit"
|
||||||
categories = ["gui"]
|
categories = ["gui"]
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
features = ["icon_loading"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
icon_loading = ["image"]
|
icon_loading = ["image"]
|
||||||
|
|
||||||
|
|
10
src/icon.rs
10
src/icon.rs
|
@ -104,12 +104,16 @@ impl Icon {
|
||||||
|
|
||||||
#[cfg(feature = "icon_loading")]
|
#[cfg(feature = "icon_loading")]
|
||||||
/// Loads an `Icon` from the path of an image on the filesystem.
|
/// Loads an `Icon` from the path of an image on the filesystem.
|
||||||
|
///
|
||||||
|
/// Requires the `icon_loading` feature.
|
||||||
pub fn from_path<P: AsRef<Path>>(path: P) -> image::ImageResult<Self> {
|
pub fn from_path<P: AsRef<Path>>(path: P) -> image::ImageResult<Self> {
|
||||||
image::open(path).map(Into::into)
|
image::open(path).map(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "icon_loading")]
|
#[cfg(feature = "icon_loading")]
|
||||||
/// Loads an `Icon` from anything implementing `BufRead` and `Seek`.
|
/// Loads an `Icon` from anything implementing `BufRead` and `Seek`.
|
||||||
|
///
|
||||||
|
/// Requires the `icon_loading` feature.
|
||||||
pub fn from_reader<R: BufRead + Seek>(
|
pub fn from_reader<R: BufRead + Seek>(
|
||||||
reader: R,
|
reader: R,
|
||||||
format: image::ImageFormat,
|
format: image::ImageFormat,
|
||||||
|
@ -120,12 +124,16 @@ impl Icon {
|
||||||
#[cfg(feature = "icon_loading")]
|
#[cfg(feature = "icon_loading")]
|
||||||
/// Loads an `Icon` from the unprocessed bytes of an image file.
|
/// Loads an `Icon` from the unprocessed bytes of an image file.
|
||||||
/// Uses heuristics to determine format.
|
/// Uses heuristics to determine format.
|
||||||
|
///
|
||||||
|
/// Requires the `icon_loading` feature.
|
||||||
pub fn from_bytes(bytes: &[u8]) -> image::ImageResult<Self> {
|
pub fn from_bytes(bytes: &[u8]) -> image::ImageResult<Self> {
|
||||||
image::load_from_memory(bytes).map(Into::into)
|
image::load_from_memory(bytes).map(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "icon_loading")]
|
#[cfg(feature = "icon_loading")]
|
||||||
/// Loads an `Icon` from the unprocessed bytes of an image.
|
/// Loads an `Icon` from the unprocessed bytes of an image.
|
||||||
|
///
|
||||||
|
/// Requires the `icon_loading` feature.
|
||||||
pub fn from_bytes_with_format(
|
pub fn from_bytes_with_format(
|
||||||
bytes: &[u8],
|
bytes: &[u8],
|
||||||
format: image::ImageFormat,
|
format: image::ImageFormat,
|
||||||
|
@ -135,6 +143,7 @@ impl Icon {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "icon_loading")]
|
#[cfg(feature = "icon_loading")]
|
||||||
|
/// Requires the `icon_loading` feature.
|
||||||
impl From<image::DynamicImage> for Icon {
|
impl From<image::DynamicImage> for Icon {
|
||||||
fn from(image: image::DynamicImage) -> Self {
|
fn from(image: image::DynamicImage) -> Self {
|
||||||
use image::{GenericImage, Pixel};
|
use image::{GenericImage, Pixel};
|
||||||
|
@ -148,6 +157,7 @@ impl From<image::DynamicImage> for Icon {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "icon_loading")]
|
#[cfg(feature = "icon_loading")]
|
||||||
|
/// Requires the `icon_loading` feature.
|
||||||
impl From<image::RgbaImage> for Icon {
|
impl From<image::RgbaImage> for Icon {
|
||||||
fn from(buf: image::RgbaImage) -> Self {
|
fn from(buf: image::RgbaImage) -> Self {
|
||||||
let (width, height) = buf.dimensions();
|
let (width, height) = buf.dimensions();
|
||||||
|
|
Loading…
Add table
Reference in a new issue