Download packages/tauri-plugins/plugins/window-state/src/cmd.rs from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri-plugins/plugins/window-state/src/cmd.rs
- Command line
-
hf download hf://datasets/echodict/readest/packages/tauri-plugins/plugins/window-state/src/cmd.rs
-
curl -L -o cmd.rs https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri-plugins/plugins/window-state/src/cmd.rs
1.4 kB
| // Copyright 2019-2023 Tauri Programme within The Commons Conservancy | |
| // SPDX-License-Identifier: Apache-2.0 | |
| // SPDX-License-Identifier: MIT | |
| use crate::{AppHandleExt, StateFlags, WindowExt}; | |
| use tauri::{command, AppHandle, Manager, Runtime}; | |
| fn get_state_flags<R: Runtime>( | |
| app: &AppHandle<R>, | |
| flags: Option<u32>, | |
| ) -> std::result::Result<StateFlags, String> { | |
| let flags = if let Some(flags) = flags { | |
| StateFlags::from_bits(flags).ok_or_else(|| format!("Invalid state flags bits: {flags}"))? | |
| } else { | |
| let plugin_state = app.state::<crate::PluginState>(); | |
| plugin_state.state_flags | |
| }; | |
| Ok(flags) | |
| } | |
| pub async fn save_window_state<R: Runtime>( | |
| app: AppHandle<R>, | |
| flags: Option<u32>, | |
| ) -> std::result::Result<(), String> { | |
| let flags = get_state_flags(&app, flags)?; | |
| app.save_window_state(flags).map_err(|e| e.to_string())?; | |
| Ok(()) | |
| } | |
| pub async fn restore_state<R: Runtime>( | |
| app: AppHandle<R>, | |
| label: String, | |
| flags: Option<u32>, | |
| ) -> std::result::Result<(), String> { | |
| let flags = get_state_flags(&app, flags)?; | |
| app.get_webview_window(&label) | |
| .ok_or_else(|| format!("Couldn't find window with label: {label}"))? | |
| .restore_state(flags) | |
| .map_err(|e| e.to_string())?; | |
| Ok(()) | |
| } | |
| pub fn filename<R: Runtime>(app: AppHandle<R>) -> String { | |
| app.filename() | |
| } | |