-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from geofmureithi/feat/plugy-arity
feat: plugin functions can have multiple arity
- Loading branch information
Showing
5 changed files
with
21 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
use plugy_macros::plugin_impl; | ||
use shared::Greeter; | ||
use serde::Deserialize; | ||
use shared::Greeter; | ||
|
||
#[derive(Debug, Deserialize)] | ||
struct FooPlugin; | ||
|
||
#[plugin_impl] | ||
impl Greeter for FooPlugin { | ||
fn greet(&self) -> String { | ||
"Hello From Foo Plugin".to_owned() | ||
fn greet(&self, name: String, last_name: Option<String>) -> String { | ||
let last_name = last_name.unwrap_or_default(); | ||
format!("Hello From Foo Plugin to {name} {last_name}") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#[plugy_macros::plugin] | ||
pub trait Greeter { | ||
fn greet(&self) -> String; | ||
} | ||
fn greet(&self, name: String, last_name: Option<String>) -> String; | ||
} |