added a modify data function for changing the data_to_send mutex
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user