added a modify data function for changing the data_to_send mutex

This commit is contained in:
2026-05-16 12:40:00 +01:00
parent 9d2f615e16
commit a251be7827
6 changed files with 37 additions and 28 deletions
+20
View File
@@ -3,6 +3,7 @@ use crate::
{
// internal code
character,
UnwrapOrExit,
// libraries
json,
HashMap,
@@ -101,3 +102,22 @@ pub async fn api_process
.run(([127, 0, 0, 1],config::API_PORT))
.await;
}
// On fail, quit safely
// If successful, return nothing
pub fn modify_data
(
data_to_send: &Arc<Mutex<DataToSend>>,
action_type: String,
content: String,
character_name: String,
choices: Vec<String>,
)
{
let mut data = data_to_send.lock().unwrap_or_exit("Data to send Mutex was poisoned",2); // TODO eh?
data.action_type = action_type;
data.content = content;
data.character = character_name;
data.choices = choices;
drop(data);
}