A Frickn Chickn
A Frickn Chickn
DDeno
Created by A Frickn Chickn on 6/17/2024 in #help
How do you define an op in rust to return a string?
#[deno_core::op2(async)]
async fn op_fetch(#[string] req: String) -> String {
async { "hello".to_string() }.await
}
#[deno_core::op2(async)]
async fn op_fetch(#[string] req: String) -> String {
async { "hello".to_string() }.await
}
fails to compile
70 | #[deno_core::op2(async)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: message: Failed to parse #[op2]:
- Failed to parse signature
- Invalid return type
- Invalid return type
- Missing a #[string] attribute for type: String
70 | #[deno_core::op2(async)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: message: Failed to parse #[op2]:
- Failed to parse signature
- Invalid return type
- Invalid return type
- Missing a #[string] attribute for type: String
https://github.com/denoland/deno_core/blob/main/ops/op2/README.md#return-values this guide says I should mark string with #[string] String, however this also doesn't compile.
#[deno_core::op2(async)]
async fn op_fetch(#[string] req: String) -> #[string] String {
async { "hello".to_string() }.await
}
#[deno_core::op2(async)]
async fn op_fetch(#[string] req: String) -> #[string] String {
async { "hello".to_string() }.await
}
71 | async fn op_fetch2(#[string] req: String) -> #[string] String {
| ^ expected type
71 | async fn op_fetch2(#[string] req: String) -> #[string] String {
| ^ expected type
5 replies