Skip to content

Commit

Permalink
Fix/context export (#37)
Browse files Browse the repository at this point in the history
* fix: improves context api

* fix: update context api

* docs: improve example

* fix: generalize plugin type

* improve: types and examples

* clippy: minor clippy fixes

* docs: ensure running

* fix: macro types
  • Loading branch information
geofmureithi authored Dec 3, 2023
1 parent dc3274d commit 8b8aeda
Show file tree
Hide file tree
Showing 10 changed files with 405 additions and 200 deletions.
104 changes: 90 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To use plugy in your Rust project, follow these steps:

1. Write your plugin trait:

```rust
```rust,ignore
#[plugy::plugin]
trait Greeter {
fn greet(&self) -> String;
Expand All @@ -29,7 +29,7 @@ trait Greeter {

2. Write your first plugin implementation

```rust
```rust,ignore
#[derive(Debug, Deserialize)]
struct FooPlugin;
Expand All @@ -43,13 +43,13 @@ impl Greeter for FooPlugin {

Compile it!

```
```bash,ignore
cargo build --target wasm32-unknown-unknown
```

3. Import and run

```rust
```rust,ignore
#[plugin_import(file = "target/wasm32-unknown-unknown/debug/foo_plugin.wasm")]
struct FooPlugin;
Expand Down
2 changes: 1 addition & 1 deletion crates/plugy-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub trait PluginLoader {
///
/// Returns a `Pin<Box<dyn Future<Output = Result<Vec<u8>, anyhow::Error>>>>`
/// representing the asynchronous loading process.
fn load(&self) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, anyhow::Error>>>>;
fn bytes(&self) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, anyhow::Error>>>>;

/// A plugins name should be known before loading.
/// It might just be `std::any::type_name::<Self>()`
Expand Down
3 changes: 2 additions & 1 deletion crates/plugy-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ proc-macro = true
quote = "1.0"
syn = { features = ["full", "parsing"], version = "2.0" }
proc-macro2 = "1"
darling = "0.20.3"
darling = "0.20.3"
convert_case = "0.6.0"
Loading

0 comments on commit 8b8aeda

Please sign in to comment.