Download packages/tauri-plugins/plugins/shell/src/scope_entry.rs from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 1.94 kB
-
https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri-plugins/plugins/shell/src/scope_entry.rs
- Command line
-
hf download hf://datasets/echodict/readest/packages/tauri-plugins/plugins/shell/src/scope_entry.rs
-
curl -L -o scope_entry.rs https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri-plugins/plugins/shell/src/scope_entry.rs
1.94 kB
| // Copyright 2019-2023 Tauri Programme within The Commons Conservancy | |
| // SPDX-License-Identifier: Apache-2.0 | |
| // SPDX-License-Identifier: MIT | |
| use serde::{de::Error as DeError, Deserialize, Deserializer}; | |
| use std::path::PathBuf; | |
| /// A command allowed to be executed by the webview API. | |
| pub(crate) struct Entry { | |
| pub(crate) name: String, | |
| pub(crate) command: PathBuf, | |
| pub(crate) args: ShellAllowedArgs, | |
| pub(crate) sidecar: bool, | |
| } | |
| pub(crate) struct EntryRaw { | |
| pub(crate) name: String, | |
| pub(crate) command: Option<PathBuf>, | |
| pub(crate) args: ShellAllowedArgs, | |
| pub(crate) sidecar: bool, | |
| } | |
| impl<'de> Deserialize<'de> for Entry { | |
| fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | |
| where | |
| D: Deserializer<'de>, | |
| { | |
| let config = EntryRaw::deserialize(deserializer)?; | |
| if !config.sidecar && config.command.is_none() { | |
| return Err(DeError::custom( | |
| "The shell scope `command` value is required.", | |
| )); | |
| } | |
| Ok(Entry { | |
| name: config.name, | |
| command: config.command.unwrap_or_default(), | |
| args: config.args, | |
| sidecar: config.sidecar, | |
| }) | |
| } | |
| } | |
| pub enum ShellAllowedArgs { | |
| Flag(bool), | |
| List(Vec<ShellAllowedArg>), | |
| } | |
| impl Default for ShellAllowedArgs { | |
| fn default() -> Self { | |
| Self::Flag(false) | |
| } | |
| } | |
| pub enum ShellAllowedArg { | |
| Fixed(String), | |
| Var { | |
| validator: String, | |
| raw: bool, | |
| }, | |
| } | |