create_ipc_handler

Function create_ipc_handler 

Source
pub fn create_ipc_handler<H, R: Runtime>(
    procedures: H,
) -> impl Fn(Invoke<R>) -> bool + Send + Sync + 'static
where H: TauRpcHandler<R> + Send + Sync + 'static + Clone,
Expand description

Creates a handler that allows your IPCs to be called from the frontend with the coresponding types. Accepts a struct in which your taurpc::procedures trait is implemented. If you have nested routes, look at taurpc::Router.

ยงExamples

#[taurpc::procedures]
trait Api {
    async fn hello_world();
}

#[derive(Clone)]
struct ApiImpl;
#[taurpc::resolvers]
impl Api for ApiImpl {
    async fn hello_world(self) {
        println!("Hello world");
    }
}

#[tokio::main]
async fn main() {
  tauri::Builder::default()
    .invoke_handler(
      taurpc::create_ipc_handler(ApiImpl.into_handler());
    )
    .run(tauri::generate_context!())
    .expect("error while running tauri application");
}