Skip to main content

rlobkit_dialogs/
lib.rs

1//! rlobkit-dialogs: unified file/directory picker and save dialog API.
2
3pub mod blocking;
4pub mod mode;
5pub mod picker;
6pub mod types;
7
8#[cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))]
9mod desktop;
10
11#[cfg(target_arch = "wasm32")]
12mod wasm;
13
14#[cfg(target_os = "android")]
15mod android;
16
17#[cfg(target_os = "android")]
18pub use android::{
19    helper_activity_available_for_host, init_shared_pending_state, init_with_context,
20    on_activity_result, on_activity_result_from_intent, take_writable_fd_for_uri,
21};
22
23#[cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))]
24pub use blocking::{
25    blocking_open_file, blocking_pick_directory, blocking_pick_files, blocking_save_file,
26};
27
28pub use mode::RlobKitMode;
29pub use picker::{OpenDirectoryOptions, OpenFileOptions, RlobKit, SaveFileOptions};
30pub use rlobkit_core::{PlatformDirectory, PlatformFile, RlobKitError};
31pub use types::RlobKitType;
32
33/// Register platform-specific I/O callbacks. Must be called once at app
34/// startup on Android before any `PlatformFile::read_bytes` or
35/// `PlatformFile::write_bytes` is invoked on a URI-backed file. No-op on
36/// other platforms.
37pub fn init() {
38    #[cfg(target_os = "android")]
39    {
40        android::init();
41    }
42}
43
44pub fn init_with_android_context(
45    #[cfg(target_os = "android")] vm: *mut std::ffi::c_void,
46    #[cfg(target_os = "android")] context: *mut std::ffi::c_void,
47) {
48    #[cfg(target_os = "android")]
49    {
50        unsafe { android::init_with_context(vm, context) };
51    }
52}