Download packages/tauri/examples/api/src-tauri/tauri-plugin-sample/src/desktop.rs from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 776 Bytes
-
https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri/examples/api/src-tauri/tauri-plugin-sample/src/desktop.rs
- Command line
-
hf download hf://datasets/echodict/readest/packages/tauri/examples/api/src-tauri/tauri-plugin-sample/src/desktop.rs
-
curl -L -o desktop.rs https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri/examples/api/src-tauri/tauri-plugin-sample/src/desktop.rs
776 Bytes
| // Copyright 2019-2024 Tauri Programme within The Commons Conservancy | |
| // SPDX-License-Identifier: Apache-2.0 | |
| // SPDX-License-Identifier: MIT | |
| use serde::de::DeserializeOwned; | |
| use tauri::{plugin::PluginApi, AppHandle, Runtime}; | |
| use crate::models::*; | |
| pub fn init<R: Runtime, C: DeserializeOwned>( | |
| app: &AppHandle<R>, | |
| _api: PluginApi<R, C>, | |
| ) -> crate::Result<Sample<R>> { | |
| Ok(Sample(app.clone())) | |
| } | |
| /// A helper class to access the sample APIs. | |
| pub struct Sample<R: Runtime>(AppHandle<R>); | |
| impl<R: Runtime> Sample<R> { | |
| pub fn ping(&self, payload: PingRequest) -> crate::Result<PingResponse> { | |
| payload.on_event.send(Event { | |
| kind: "ping".to_string(), | |
| value: payload.value.clone(), | |
| })?; | |
| Ok(PingResponse { | |
| value: payload.value, | |
| }) | |
| } | |
| } | |