Skip to main content

iced_core/
window.rs

1//! Build window-based GUI applications.
2pub mod icon;
3pub mod screenshot;
4pub mod settings;
5
6mod direction;
7mod event;
8mod id;
9mod level;
10mod mode;
11mod position;
12mod redraw_request;
13mod user_attention;
14
15pub use direction::Direction;
16pub use event::Event;
17pub use icon::Icon;
18pub use id::Id;
19pub use level::Level;
20pub use mode::Mode;
21pub use position::Position;
22pub use redraw_request::RedrawRequest;
23pub use screenshot::Screenshot;
24pub use settings::Settings;
25pub use user_attention::UserAttention;
26
27use raw_window_handle::{
28    DisplayHandle, HandleError, HasDisplayHandle, HasWindowHandle, WindowHandle,
29};
30use std::fmt::Debug;
31
32pub use raw_window_handle;
33
34/// A window managed by iced.
35///
36/// It implements both [`HasWindowHandle`] and [`HasDisplayHandle`].
37pub trait Window: HasWindowHandle + HasDisplayHandle + Debug {}
38
39impl<T> Window for T where T: HasWindowHandle + HasDisplayHandle + Debug {}
40
41/// A headless window.
42#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
43pub struct Headless;
44
45impl HasWindowHandle for Headless {
46    fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError> {
47        Err(HandleError::NotSupported)
48    }
49}
50
51impl HasDisplayHandle for Headless {
52    fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError> {
53        Err(HandleError::NotSupported)
54    }
55}