libspkg

Crates.iolibspkg
lib.rslibspkg
version0.1.6
sourcesrc
created_at2024-07-16 20:35:24.96669
updated_at2024-08-14 21:30:51.286435
descriptionSpkg Rust Library
homepagehttps://strawberryfoundations.org
repositoryhttps://github.com/Strawberry-Foundations/libspkg
max_upload_size
id1305494
size48,377
Julian (Juliandev02)

documentation

README

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)
}
Commit count: 0

cargo fmt