diff options
Diffstat (limited to 'test_plugin/src/lib.rs')
-rw-r--r-- | test_plugin/src/lib.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/test_plugin/src/lib.rs b/test_plugin/src/lib.rs index 56eb8d489..0626ef3c3 100644 --- a/test_plugin/src/lib.rs +++ b/test_plugin/src/lib.rs @@ -13,6 +13,7 @@ use deno_core::OpState; use deno_core::Resource; use deno_core::ResourceId; use deno_core::ZeroCopyBuf; +use serde::Deserialize; #[no_mangle] pub fn init() -> Extension { @@ -32,13 +33,20 @@ pub fn init() -> Extension { .build() } +#[derive(Debug, Deserialize)] +struct TestArgs { + val: String, +} + fn op_test_sync( _state: &mut OpState, - _args: (), + args: TestArgs, zero_copy: Option<ZeroCopyBuf>, ) -> Result<String, AnyError> { println!("Hello from sync plugin op."); + println!("args: {:?}", args); + if let Some(buf) = zero_copy { let buf_str = std::str::from_utf8(&buf[..])?; println!("zero_copy: {}", buf_str); @@ -49,11 +57,13 @@ fn op_test_sync( async fn op_test_async( _state: Rc<RefCell<OpState>>, - _args: (), + args: TestArgs, zero_copy: Option<ZeroCopyBuf>, ) -> Result<String, AnyError> { println!("Hello from async plugin op."); + println!("args: {:?}", args); + if let Some(buf) = zero_copy { let buf_str = std::str::from_utf8(&buf[..])?; println!("zero_copy: {}", buf_str); |