desktop.rs 665 B

1234567891011121314151617181920212223242526
  1. // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. use serde::de::DeserializeOwned;
  5. use tauri::{plugin::PluginApi, AppHandle, Runtime};
  6. use crate::models::*;
  7. pub fn init<R: Runtime, C: DeserializeOwned>(
  8. app: &AppHandle<R>,
  9. _api: PluginApi<R, C>,
  10. ) -> crate::Result<Sample<R>> {
  11. Ok(Sample(app.clone()))
  12. }
  13. /// A helper class to access the sample APIs.
  14. pub struct Sample<R: Runtime>(AppHandle<R>);
  15. impl<R: Runtime> Sample<R> {
  16. pub fn ping(&self, payload: PingRequest) -> crate::Result<PingResponse> {
  17. Ok(PingResponse {
  18. value: payload.value,
  19. })
  20. }
  21. }