Skip to content

Commit

Permalink
feat(plugin): init all interface
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Feb 18, 2021
1 parent a78d077 commit 36e8e25
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
32 changes: 31 additions & 1 deletion plugins/coco_coverage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,38 @@ use std::{process, thread};

use grcov::*;

use core_model::CocoConfig;
use plugin_interface::PluginInterface;

pub struct CocoCoverage {}

impl PluginInterface for CocoCoverage {
fn name(&self) -> &'static str {
"coco.coverage"
}

fn on_plugin_load(&self) {}

fn on_plugin_unload(&self) {}

fn execute(&self, config: CocoConfig) {
println!("{:?}", config);
}
}

impl Default for CocoCoverage {
fn default() -> Self {
CocoCoverage {}
}
}

#[no_mangle]
pub fn plugin() -> Box<dyn PluginInterface> {
Box::new(CocoCoverage::default())
}

#[allow(dead_code)]
fn main() {
fn run() {
let default_num_threads = 1.max(num_cpus::get() - 1).to_string();

let matches = App::new("grcov")
Expand Down
31 changes: 28 additions & 3 deletions plugins/coco_struct_analysis/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
#[allow(dead_code)]
fn main() {
println!("Hello, world!");
use core_model::CocoConfig;
use plugin_interface::PluginInterface;

pub struct CocoStructAnslysis {}

impl PluginInterface for CocoStructAnslysis {
fn name(&self) -> &'static str {
"coco.struct_analysis"
}

fn on_plugin_load(&self) {}

fn on_plugin_unload(&self) {}

fn execute(&self, config: CocoConfig) {
println!("{:?}", config);
}
}

impl Default for CocoStructAnslysis {
fn default() -> Self {
CocoStructAnslysis {}
}
}

#[no_mangle]
pub fn plugin() -> Box<dyn PluginInterface> {
Box::new(CocoStructAnslysis::default())
}

0 comments on commit 36e8e25

Please sign in to comment.