Skip to content

Commit be19354

Browse files
committed
feat: add rust plugin template
1 parent 511dd38 commit be19354

25 files changed

Lines changed: 3039 additions & 26 deletions

packages/cli/src/commands/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const urlStr = intlMsg.commands_create_options_t_url();
2929
export const supportedLangs = {
3030
wasm: ["assemblyscript", "rust", "interface"] as const,
3131
app: ["typescript"] as const,
32-
plugin: ["typescript"] as const,
32+
plugin: ["typescript", "rust", "python"] as const,
3333
};
3434

3535
export type ProjectType = keyof typeof supportedLangs;
File renamed without changes.

packages/templates/app/typescript/polywrap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ project:
33
name: Sample
44
type: app/typescript
55
source:
6-
schema: ./schema.graphql
6+
schema: ./polywrap.graphql
File renamed without changes.

packages/templates/plugin/python/polywrap.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ project:
33
name: Sample
44
type: plugin/python
55
source:
6-
schema: ./schema.graphql
7-
module: ./sample/__init__.py
6+
schema: ./polywrap.graphql
7+
module: ./sample/__init__.py
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "template_plugin_rs"
3+
version = "0.1.0"
4+
license = "MIT"
5+
description = "Polywrap Rust Plugin Template"
6+
edition = "2021"
7+
8+
include = [
9+
"src/wrap/*",
10+
"src/lib.rs"
11+
]
12+
13+
[dependencies]
14+
polywrap_core = { version = "0.1.6-beta.1" }
15+
polywrap_plugin = { version = "0.1.6-beta.1" }
16+
polywrap_msgpack = { version = "0.1.6-beta.1" }
17+
wrap_manifest_schemas = { version = "0.1.6-beta.1" }
18+
serde = {version = "1.0.145", features = ["derive"]}
19+
20+
[dev-dependencies]
21+
polywrap_client = { version = "~0.1.6-beta.1" }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "templates-plugin-rust",
3+
"private": true,
4+
"dependencies": {
5+
"polywrap": "~0.10.2"
6+
}
7+
}
File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
format: 0.3.0
2+
project:
3+
name: Sample
4+
type: plugin/rust
5+
source:
6+
schema: ./polywrap.graphql
7+
module: ./Cargo.toml
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use crate::wrap::wrap_info::get_manifest;
2+
use polywrap_core::invoke::Invoker;
3+
use polywrap_plugin::{error::PluginError, implementor::plugin_impl, JSON};
4+
use wrap::{
5+
module::{ArgsSampleMethod, Module},
6+
};
7+
use std::{sync::Arc};
8+
pub mod wrap;
9+
10+
#[derive(Debug)]
11+
pub struct SamplePlugin {}
12+
13+
#[plugin_impl]
14+
impl Module for SamplePlugin {
15+
fn sample_method(
16+
&mut self,
17+
args: &ArgsSampleMethod,
18+
_: Arc<dyn Invoker>,
19+
) -> Result<String, PluginError> {
20+
Ok(format!("{:} from sample_method", args.data).to_string())
21+
}
22+
}

0 commit comments

Comments
 (0)