Download packages/tauri-plugins/plugins/geolocation/src/lib.rs from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri-plugins/plugins/geolocation/src/lib.rs
- Command line
-
hf download hf://datasets/echodict/readest/packages/tauri-plugins/plugins/geolocation/src/lib.rs
-
curl -L -o lib.rs https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri-plugins/plugins/geolocation/src/lib.rs
1.51 kB
| // Copyright 2019-2023 Tauri Programme within The Commons Conservancy | |
| // SPDX-License-Identifier: Apache-2.0 | |
| // SPDX-License-Identifier: MIT | |
| use tauri::{ | |
| plugin::{Builder, TauriPlugin}, | |
| Manager, Runtime, | |
| }; | |
| pub use models::*; | |
| mod desktop; | |
| mod mobile; | |
| mod commands; | |
| mod error; | |
| mod models; | |
| pub use error::{Error, Result}; | |
| pub use desktop::Geolocation; | |
| pub use mobile::Geolocation; | |
| /// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the geolocation APIs. | |
| pub trait GeolocationExt<R: Runtime> { | |
| fn geolocation(&self) -> &Geolocation<R>; | |
| } | |
| impl<R: Runtime, T: Manager<R>> crate::GeolocationExt<R> for T { | |
| fn geolocation(&self) -> &Geolocation<R> { | |
| self.state::<Geolocation<R>>().inner() | |
| } | |
| } | |
| /// Initializes the plugin. | |
| pub fn init<R: Runtime>() -> TauriPlugin<R> { | |
| Builder::new("geolocation") | |
| .invoke_handler(tauri::generate_handler![ | |
| commands::get_current_position, | |
| commands::watch_position, | |
| commands::clear_watch, | |
| commands::check_permissions, | |
| commands::request_permissions | |
| ]) | |
| .setup(|app, api| { | |
| let geolocation = mobile::init(app, api)?; | |
| let geolocation = desktop::init(app, api)?; | |
| app.manage(geolocation); | |
| Ok(()) | |
| }) | |
| .build() | |
| } | |