nexus\api/alert.rs
1//! Alert notifications displayed to the user.
2
3use crate::{util::str_to_c, AddonApi, UiApi};
4use std::ffi::c_char;
5
6pub type RawAlertNotify = unsafe extern "C-unwind" fn(message: *const c_char);
7
8/// Sends an alert that is visible to the user for a short amount of time.
9pub fn send_alert(message: impl AsRef<str>) {
10 let message = str_to_c(message, "failed to convert alert message");
11 let UiApi { send_alert, .. } = AddonApi::get().ui;
12 unsafe { send_alert(message.as_ptr()) }
13}