pub struct SetCallbackError(/* private fields */);Expand description
Error returned when installing a process-global callback whose slot is already occupied.
Each callback slot in crate::core::callbacks (set_save_file_data_callback,
set_load_file_data_callback, set_save_file_text_callback,
set_load_file_text_callback) holds at most one function at a time. Calling a setter
while its slot is occupied returns this error rather than silently overwriting. The inner
&'static str names which callback kind was already set (e.g. "save file data").
Cause: A previous call to the same setter installed a callback that has not been removed.
Recovery: Keep a single registration site per callback kind, or remove the existing callback (where an unset function exists) before installing a new one.
§Examples
use raylib::prelude::*;
use raylib::core::callbacks::set_save_file_data_callback;
fn writer(_path: &str, _bytes: &[u8]) -> bool { true }
set_save_file_data_callback(writer).expect("first install");
match set_save_file_data_callback(writer) {
Err(e) => eprintln!("{e}"), // "there is a save file data callback already set"
Ok(()) => unreachable!(),
}Trait Implementations§
Source§impl Debug for SetCallbackError
impl Debug for SetCallbackError
Source§impl Display for SetCallbackError
impl Display for SetCallbackError
Source§impl Error for SetCallbackError
impl Error for SetCallbackError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()