1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! How commands are linked into the engine's registry.
use crateCvar;
use NonNull;
/// Links console commands and variables into, and unlinks them from, the
/// engine's `ICvar`.
///
/// # Safety
///
/// `link` must pass `command` unchanged to `ICvar::RegisterConCommand`, and
/// `unlink` to `ICvar::UnregisterConCommand`, directly or through a host such
/// as Metamod:Source. Neither may keep the pointer except as the engine or
/// that host does.
pub unsafe
// SAFETY: These are direct calls to the engine's registry. Nothing unlinks the
// commands on unload, so `Cvar` is not `UnlinksBeforeUnload`.
unsafe
/// A registrar whose host unlinks every command linked through it before
/// unloading the module that contains the command's code.
///
/// This is what makes [`ConsoleCommand::register`] safe: the engine can never
/// call a command whose code is gone, even when the plugin forgets to
/// unregister it or its host unloads it by force.
///
/// # Safety
///
/// Every command linked through this registrar must be unlinked after the
/// plugin's last callback and before its library is unloaded, including when
/// the host refuses the plugin's load or unloads it by force.
///
/// [`ConsoleCommand::register`]: super::ConsoleCommand::register
pub unsafe