Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/denosaurs/deno_json_op
📋 A macro for easing the development of deno plugins
https://github.com/denosaurs/deno_json_op
deno deno-plugin deno-plugins macro
Last synced: 3 months ago
JSON representation
📋 A macro for easing the development of deno plugins
- Host: GitHub
- URL: https://github.com/denosaurs/deno_json_op
- Owner: denosaurs
- License: mit
- Archived: true
- Created: 2020-11-12T11:47:49.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-12T17:49:55.000Z (about 4 years ago)
- Last Synced: 2024-05-21T19:37:27.145Z (7 months ago)
- Topics: deno, deno-plugin, deno-plugins, macro
- Language: Rust
- Homepage: https://crates.io/crates/deno_json_op
- Size: 8.79 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# deno_json_op
This is a crate for easing the building of deno plugins by providing a simple
macro which automatically converts the first element in the `ZeroCopy` to a
`serde_json::Value` and the `Result<_, _>` to a json object.## Usage
```rust
use deno_core::error::AnyError;use deno_core::plugin_api::Interface;
use deno_core::plugin_api::Op;
use deno_core::plugin_api::ZeroCopyBuf;use deno_core::serde_json::Value;
use deno_core::serde_json::json;use deno_json_op::json_op;
#[no_mangle]
pub fn deno_plugin_init(interface: &mut dyn Interface) {
interface.register_op("test", op_test);
}#[json_op]
fn op_test(_interface: &mut dyn Interface, val: Value, _zero_copy: &mut [ZeroCopyBuf]) -> Result {
Ok(json!({
"hello": val
}))
}
```## Other
### Related
- [calcite](https://github.com/Srinivasa314/calcite) - similar project
### Contribution
Pull request, issues and feedback are very welcome. Code style is formatted with
`deno fmt` and commit messages are done following Conventional Commits spec.### Licence
Copyright 2020-present, the denosaurs team. All rights reserved. MIT license.