Download packages/tauri-plugins/plugins/dialog/src/models.rs from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 3.1 kB
-
https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri-plugins/plugins/dialog/src/models.rs
- Command line
-
hf download hf://datasets/echodict/readest/packages/tauri-plugins/plugins/dialog/src/models.rs
-
curl -L -o models.rs https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri-plugins/plugins/dialog/src/models.rs
3.1 kB
| // Copyright 2019-2023 Tauri Programme within The Commons Conservancy | |
| // SPDX-License-Identifier: Apache-2.0 | |
| // SPDX-License-Identifier: MIT | |
| use serde::{Deserialize, Deserializer, Serialize, Serializer}; | |
| /// Types of message, ask and confirm dialogs. | |
| pub enum MessageDialogKind { | |
| /// Information dialog. | |
| Info, | |
| /// Warning dialog. | |
| Warning, | |
| /// Error dialog. | |
| Error, | |
| } | |
| impl<'de> Deserialize<'de> for MessageDialogKind { | |
| fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | |
| where | |
| D: Deserializer<'de>, | |
| { | |
| let s = String::deserialize(deserializer)?; | |
| Ok(match s.to_lowercase().as_str() { | |
| "info" => MessageDialogKind::Info, | |
| "warning" => MessageDialogKind::Warning, | |
| "error" => MessageDialogKind::Error, | |
| _ => MessageDialogKind::Info, | |
| }) | |
| } | |
| } | |
| impl Serialize for MessageDialogKind { | |
| fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error> | |
| where | |
| S: Serializer, | |
| { | |
| match self { | |
| Self::Info => serializer.serialize_str("info"), | |
| Self::Warning => serializer.serialize_str("warning"), | |
| Self::Error => serializer.serialize_str("error"), | |
| } | |
| } | |
| } | |
| /// Set of button that will be displayed on the dialog | |
| pub enum MessageDialogButtons { | |
| /// A single `Ok` button with OS default dialog text | |
| Ok, | |
| /// 2 buttons `Ok` and `Cancel` with OS default dialog texts | |
| OkCancel, | |
| /// 2 buttons `Yes` and `No` with OS default dialog texts | |
| YesNo, | |
| /// 3 buttons `Yes`, `No` and `Cancel` with OS default dialog texts | |
| YesNoCancel, | |
| /// A single `Ok` button with custom text | |
| OkCustom(String), | |
| /// 2 buttons `Ok` and `Cancel` with custom texts | |
| OkCancelCustom(String, String), | |
| /// 3 buttons `Yes`, `No` and `Cancel` with custom texts | |
| YesNoCancelCustom(String, String, String), | |
| } | |
| /// Result of a message dialog | |
| pub enum MessageDialogResult { | |
| Yes, | |
| No, | |
| Ok, | |
| Cancel, | |
| Custom(String), | |
| } | |
| impl From<rfd::MessageDialogResult> for MessageDialogResult { | |
| fn from(result: rfd::MessageDialogResult) -> Self { | |
| match result { | |
| rfd::MessageDialogResult::Yes => Self::Yes, | |
| rfd::MessageDialogResult::No => Self::No, | |
| rfd::MessageDialogResult::Ok => Self::Ok, | |
| rfd::MessageDialogResult::Cancel => Self::Cancel, | |
| rfd::MessageDialogResult::Custom(s) => Self::Custom(s), | |
| } | |
| } | |
| } | |
| impl From<String> for MessageDialogResult { | |
| fn from(value: String) -> Self { | |
| match value.as_str() { | |
| "Yes" => Self::Yes, | |
| "No" => Self::No, | |
| "Ok" => Self::Ok, | |
| "Cancel" => Self::Cancel, | |
| _ => Self::Custom(value), | |
| } | |
| } | |
| } | |