Download packages/tauri-plugins/plugins/notification/src/commands.rs from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri-plugins/plugins/notification/src/commands.rs
- Command line
-
hf download hf://datasets/echodict/readest/packages/tauri-plugins/plugins/notification/src/commands.rs
-
curl -L -o commands.rs https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri-plugins/plugins/notification/src/commands.rs
1.17 kB
| // Copyright 2019-2023 Tauri Programme within The Commons Conservancy | |
| // SPDX-License-Identifier: Apache-2.0 | |
| // SPDX-License-Identifier: MIT | |
| use tauri::{command, plugin::PermissionState, AppHandle, Runtime, State}; | |
| use crate::{Notification, NotificationData, Result}; | |
| pub(crate) async fn is_permission_granted<R: Runtime>( | |
| _app: AppHandle<R>, | |
| notification: State<'_, Notification<R>>, | |
| ) -> Result<Option<bool>> { | |
| let state = notification.permission_state()?; | |
| match state { | |
| PermissionState::Granted => Ok(Some(true)), | |
| PermissionState::Denied => Ok(Some(false)), | |
| PermissionState::Prompt | PermissionState::PromptWithRationale => Ok(None), | |
| } | |
| } | |
| pub(crate) async fn request_permission<R: Runtime>( | |
| _app: AppHandle<R>, | |
| notification: State<'_, Notification<R>>, | |
| ) -> Result<PermissionState> { | |
| notification.request_permission() | |
| } | |
| pub(crate) async fn notify<R: Runtime>( | |
| _app: AppHandle<R>, | |
| notification: State<'_, Notification<R>>, | |
| options: NotificationData, | |
| ) -> Result<()> { | |
| let mut builder = notification.builder(); | |
| builder.data = options; | |
| builder.show() | |
| } | |