gpui_platform/
gpui_platform.rs1use std::rc::Rc;
7
8pub use gpui::Platform;
9
10pub fn background_executor() -> gpui::BackgroundExecutor {
12 current_platform(true).background_executor()
13}
14
15pub fn application() -> gpui::Application {
17 gpui::Application::with_platform(current_platform(false))
18}
19
20pub fn headless() -> gpui::Application {
22 gpui::Application::with_platform(current_platform(true))
23}
24
25#[cfg(any(target_os = "linux", target_os = "freebsd"))]
27pub fn current_platform(headless: bool) -> Rc<dyn Platform> {
28 gpui_linux::current_platform(headless)
29}
30
31#[cfg(target_os = "macos")]
33pub fn current_platform(headless: bool) -> Rc<dyn Platform> {
34 gpui_macos::current_platform(headless)
35}
36
37#[cfg(target_os = "windows")]
39pub fn current_platform(headless: bool) -> Rc<dyn Platform> {
40 gpui_windows::current_platform(headless)
41}
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn construction_entry_points_have_stable_types() {
49 let _: fn() -> gpui::Application = application;
50 let _: fn() -> gpui::Application = headless;
51 let _: fn() -> gpui::BackgroundExecutor = background_executor;
52 let _: fn(bool) -> Rc<dyn Platform> = current_platform;
53 }
54}