Rust implementation of NextGraph, a Decentralized and local-first web 3.0 ecosystem
https://nextgraph.org
byzantine-fault-tolerancecrdtsdappsdecentralizede2eeeventual-consistencyjson-ldlocal-firstmarkdownocapoffline-firstp2pp2p-networkprivacy-protectionrdfrich-text-editorself-hostedsemantic-websparqlweb3collaboration
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
49 lines
1.2 KiB
2 years ago
|
use tauri::App;
|
||
|
|
||
|
#[cfg(mobile)]
|
||
|
mod mobile;
|
||
|
#[cfg(mobile)]
|
||
|
pub use mobile::*;
|
||
|
|
||
|
pub type SetupHook = Box<dyn FnOnce(&mut App) -> Result<(), Box<dyn std::error::Error>> + Send>;
|
||
|
|
||
|
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
||
|
#[tauri::command]
|
||
|
fn greet(name: &str) -> String {
|
||
|
format!("Hello, {}! You've been greeted from Rust!", name)
|
||
|
}
|
||
|
|
||
|
#[derive(Default)]
|
||
|
pub struct AppBuilder {
|
||
|
setup: Option<SetupHook>,
|
||
|
}
|
||
|
|
||
|
impl AppBuilder {
|
||
|
pub fn new() -> Self {
|
||
|
Self::default()
|
||
|
}
|
||
|
|
||
|
#[must_use]
|
||
|
pub fn setup<F>(mut self, setup: F) -> Self
|
||
|
where
|
||
|
F: FnOnce(&mut App) -> Result<(), Box<dyn std::error::Error>> + Send + 'static,
|
||
|
{
|
||
|
self.setup.replace(Box::new(setup));
|
||
|
self
|
||
|
}
|
||
|
|
||
|
pub fn run(self) {
|
||
|
let setup = self.setup;
|
||
|
tauri::Builder::default()
|
||
|
.setup(move |app| {
|
||
|
if let Some(setup) = setup {
|
||
|
(setup)(app)?;
|
||
|
}
|
||
|
Ok(())
|
||
|
})
|
||
|
.invoke_handler(tauri::generate_handler![greet])
|
||
|
.run(tauri::generate_context!())
|
||
|
.expect("error while running tauri application");
|
||
|
}
|
||
|
}
|