Skip to content

Commit

Permalink
defense: expand Plugin system
Browse files Browse the repository at this point in the history
  • Loading branch information
DashieTM committed Jun 28, 2024
1 parent 465b791 commit 6ab81fe
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions defense/topics/plugin_system.typ
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,51 @@
```)
]

#polylux-slide[
=== Plugin API
#sourcecode(```rs
pub fn backend_startup();
pub fn backend_shutdown();
pub fn capabilities() -> PluginCapabilities;
pub fn name() -> String;
pub fn dbus_interface(cross: &mut Crossroads);
pub fn backend_tests();
```)
#pdfpc.speaker-note(```md
- explain each function
- explain why crossroads was an issue
```)
]

#polylux-slide[
=== Macros
#grid(columns: (1.2fr, 1.5fr), rows: auto, [
*Release*
#sourcecode(```rs
#[macro_export]
#[cfg(not(debug_assertions))]
macro_rules! LOG {
($message:expr) => {{}};
}```)
], [
*Debug*
#sourcecode(```rs
#[macro_export]
#[cfg(any(debug_assertions, test))]
macro_rules! LOG {
($message:expr) => {{
write_log_to_file!($message);
println!("LOG: {}", $message);
}};
}```)
])
]

#polylux-slide[
=== Testing
\
Expand Down Expand Up @@ -120,6 +165,26 @@
```)
]

#polylux-slide[
=== Threading\
#sourcecode(```rs
thread::scope(|scope| {
let wrapper = Arc::new(RwLock::new(CrossWrapper::new(&mut cross)));
for plugin in BACKEND_PLUGINS.iter() {
let wrapper_loop = wrapper.clone();
scope.spawn(move || {
// allocate plugin specific things
(plugin.startup)();
// register and insert plugin interfaces
(plugin.data)(wrapper_loop);
let _name = (plugin.name)();
LOG!(format!("Loaded plugin: {}", _name));
});
}
});
```)
]

#polylux-slide[
=== Security
\
Expand Down Expand Up @@ -175,3 +240,4 @@
- rust provides good documentation with documentation tests
```)
]

0 comments on commit 6ab81fe

Please sign in to comment.