Update to Rust programming language.
This commit is contained in:
parent
943efbfbdb
commit
f88248643b
201 changed files with 12954 additions and 1690 deletions
40
src-tauri/src/events.rs
Normal file
40
src-tauri/src/events.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
use tauri::Manager;
|
||||
|
||||
// the payload type must implement `Serialize` and `Clone`.
|
||||
#[derive(Clone, serde::Serialize)]
|
||||
pub struct Payload {
|
||||
pub data: String,
|
||||
}
|
||||
|
||||
pub enum EventTypes {
|
||||
AudioPlay,
|
||||
AssistantWaiting,
|
||||
AssistantGreet,
|
||||
CommandStart,
|
||||
CommandInProcess,
|
||||
CommandEnd,
|
||||
}
|
||||
|
||||
impl EventTypes {
|
||||
pub fn get(&self) -> &str {
|
||||
match self {
|
||||
Self::AudioPlay => "audio-play",
|
||||
Self::AssistantWaiting => "assistant-waiting",
|
||||
Self::AssistantGreet => "assistant-greet",
|
||||
Self::CommandStart => "command-start",
|
||||
Self::CommandInProcess => "command-in-process",
|
||||
Self::CommandEnd => "command-end",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn play(phrase: &str, app_handle: &tauri::AppHandle) {
|
||||
app_handle
|
||||
.emit_all(
|
||||
EventTypes::AudioPlay.get(),
|
||||
Payload {
|
||||
data: phrase.into(),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue