3 releases

0.1.6 Aug 14, 2024
0.1.5 Aug 14, 2024
0.1.4 Jul 16, 2024

#233 in Operating systems

Download history 79/week @ 2024-07-11 25/week @ 2024-07-18 1/week @ 2024-07-25 94/week @ 2024-08-08 143/week @ 2024-08-15

237 downloads per month

GPL-3.0 license

17KB
212 lines

libspkg

Spkg Rust Library

Use-case

libspkg can be used for Spkg plugins. This is also the main aspect of libspkg. There is also binpkg, but this is currently only recommended for use with spkg

Spkg Plugins

use libspkg::plugin::{Plugin, PluginProperties};
pub struct ExamplePlugin;

impl Plugin for ExamplePlugin {
     fn execute(&self, args: &[String]) {
         match args.first().unwrap().as_str() {
             "test" => {
                 println!("Example spkg plugin")
             },
             _ => self.help()
         }
     }

     fn help(&self) {
         println!("Example help message")
     }
 }

#[allow(improper_ctypes_definitions)]
#[no_mangle]
pub extern "C" fn create_plugin() -> (Box<dyn Plugin>, PluginProperties) {
    let properties: PluginProperties = PluginProperties {
        name: "Example Plugin",
        id: "example-plugin",
        package_id: "com.example.exampleplugin",
        version: env!("CARGO_PKG_VERSION"),
        library_version: libspkg::VERSION,
    };

    (Box::new(ExamplePlugin), properties)
}

Dependencies

~0–9MB
~87K SLoC