classicube_helpers\events/
chat.rs1#![allow(clippy::not_unsafe_ptr_arg_deref)]
2
3use std::os::raw::c_int;
4
5use classicube_sys::{cc_string, MsgType};
6
7use crate::make_event_handler;
8
9make_event_handler!(
10 Chat,
12 FontChanged,
13 Void,
14 ()
15);
16
17make_event_handler!(
18 Chat,
20 ChatReceived,
21 Chat,
22 (
23 {
24 name: message,
25 rust_type: String,
26 c_type: *const cc_string,
27 to_rust: |message: *const cc_string| {
28 unsafe { message.as_ref().unwrap() }.to_string()
29 },
30 },
31 {
32 name: message_type,
33 rust_type: MsgType,
34 c_type: c_int,
35 to_rust: |message_type| MsgType::try_from(message_type).unwrap(),
36 },
37 )
38);
39
40make_event_handler!(
41 Chat,
43 ChatSending,
44 Chat,
45 (
46 {
47 name: message,
48 rust_type: String,
49 c_type: *const cc_string,
50 to_rust: |message: *const cc_string| {
51 unsafe { message.as_ref().unwrap() }.to_string()
52 },
53 },
54 {
55 name: message_type,
56 rust_type: MsgType,
57 c_type: c_int,
58 to_rust: |message_type| MsgType::try_from(message_type).unwrap(),
59 },
60 )
61);
62
63make_event_handler!(
64 Chat,
66 ColCodeChanged,
67 Int,
68 (
69 {
70 name: code,
71 rust_type: c_int,
72 c_type: c_int,
73 to_rust: |code| code,
74 },
75 )
76);