Skip to content

Commit

Permalink
Add Plugin::authors(&self),Plugin::homepage(&self),Plugin::license(&s…
Browse files Browse the repository at this point in the history
…elf),Plugin::repository(&self)
  • Loading branch information
rmqtt committed Feb 18, 2024
1 parent f0ba628 commit a0bd46d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
34 changes: 28 additions & 6 deletions rmqtt-plugins/rmqtt-plugin-template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub async fn register(
default_startup: bool,
immutable: bool,
) -> Result<()> {
let name = if name.is_empty() { env!("CARGO_PKG_NAME") } else { name };
let descr = if descr.is_empty() { env!("CARGO_PKG_DESCRIPTION") } else { descr };
runtime
.plugins
.register(name, default_startup, immutable, move || -> DynPluginResult {
Expand Down Expand Up @@ -55,11 +57,6 @@ impl Plugin for Template {
Ok(())
}

#[inline]
fn name(&self) -> &str {
&self.name
}

#[inline]
async fn start(&mut self) -> Result<()> {
log::info!("{} start", self.name);
Expand All @@ -74,15 +71,40 @@ impl Plugin for Template {
Ok(true)
}

#[inline]
fn name(&self) -> &str {
&self.name
}

#[inline]
fn version(&self) -> &str {
"0.1.1"
env!("CARGO_PKG_VERSION")
}

#[inline]
fn descr(&self) -> &str {
&self.descr
}

#[inline]
fn authors(&self) -> &str {
env!("CARGO_PKG_AUTHORS")
}

#[inline]
fn homepage(&self) -> &str {
env!("CARGO_PKG_HOMEPAGE")
}

#[inline]
fn license(&self) -> &str {
env!("CARGO_PKG_LICENSE")
}

#[inline]
fn repository(&self) -> &str {
env!("CARGO_PKG_REPOSITORY")
}
}

struct HookHandler {}
Expand Down
30 changes: 25 additions & 5 deletions rmqtt/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ pub trait Plugin: Send + Sync {
Ok(())
}

#[inline]
fn name(&self) -> &str {
""
}

#[inline]
async fn get_config(&self) -> Result<serde_json::Value> {
Ok(json!({}))
Expand All @@ -43,6 +38,11 @@ pub trait Plugin: Send + Sync {
Ok(true)
}

#[inline]
fn name(&self) -> &str {
""
}

#[inline]
fn version(&self) -> &str {
"0.0.0"
Expand All @@ -53,6 +53,26 @@ pub trait Plugin: Send + Sync {
""
}

#[inline]
fn authors(&self) -> &str {
""
}

#[inline]
fn homepage(&self) -> &str {
""
}

#[inline]
fn license(&self) -> &str {
""
}

#[inline]
fn repository(&self) -> &str {
""
}

#[inline]
async fn attrs(&self) -> serde_json::Value {
serde_json::Value::Null
Expand Down

0 comments on commit a0bd46d

Please sign in to comment.