#widgets #cargo-toml #create #dev #file #plugin #rtop-rs

rtop_dev

Development librairy for creating plugin for RtopRS

13 releases (1 stable)

1.1.0 Nov 18, 2022
1.1.0-beta.1 Nov 16, 2022
1.0.0-beta.3 Sep 21, 2022
1.0.0-beta.1 Aug 29, 2022
0.1.2 May 5, 2022

#143 in Visualization

Download history 13/week @ 2024-02-26 113/week @ 2024-03-04 11/week @ 2024-03-11

137 downloads per month
Used in rtop-rs

MPL-2.0 license

34KB
622 lines

Rtop Dev

Made with Rust Use git

Developement librairy for making Rtop's Plugin

Quick Example

Rtop let you create plugin for adding custom widgets. Firstly, create a new project:

cargo new --lib MyPlugin

After that, update your Cargo.toml file. It should look like that:

[package]
name = "my_plugin"
version = "0.1.0"
edition = "2021"

[dependencies]
rtop_dev = "^1.1.0"

[lib]
name = "my_plugin"
crate-type = ["cdylib"]

Then, edit your src/lib.rs to have somethings like this:

struct FooWidget {}

impl rtop_dev::widget::Widget for FooWidget {
    fn display(&mut self, _height: i32, _width: i32) -> String {
        String::from("Hello World RTop!")
    }
}

#[no_mangle]
pub extern "Rust" fn init_foo() -> (Box<dyn rtop_dev::plugin::Plugin>, bool) {
    (Box::new(FooWidget{}), false)
}

To build your lib, simply run:

cargo build --lib --release

Your plugin should be located here target/release/libmy_plugin.so.

Remember these things, For each widget you want to create, you must make a function called init_{WIDGET} which return a Box<dyn rtop_dev::plugin::Plugin and a bool that defines if your widget should receive input from the user or not. Don't forget to add #[no_mangle] in front of each init function. Otherwise, it will not be exported

Contributors

SquitchYT

License

RTop | Mozilla Public License 2.0

Dependencies