-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ops): op2 support for buffers in async ops #60
Conversation
#[buffer] | ||
async fn op_async_buffer(#[buffer] input: JsBuffer) -> JsBuffer { | ||
input | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's late, but... it's somewhat strange that we put #[buffer]
before function definition. I'm sure it would be now a lot of work to change, but this would be lovely:
#[op2(async, core)]
async fn op_async_buffer(#[buffer] input: JsBuffer) -> #[buffer] JsBuffer {
input
}
Similarly for serde:
#[op2(core)]
fn op_foo(#[smi] rid: ResourceId) -> #[serde] SomeStruct {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is just an unfortunate side-effect of Rust syntax. There are no return-position attributes (I'll double-check).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, so there are no attributes supported in the return position. What about this?
#[returns(buffer)] fn op...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, not a big deal. It's more of a nitpick. We can revisit it some time in the future. Let's keep pushing with the current impl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Supports owned buffers in and out: