Skip to content

feat: add ArrayBuffer::from_raw_parts and from_raw_parts_shared for external buffers#683

Open
richarddd wants to merge 2 commits intoDelSkayn:masterfrom
richarddd:feat/array-buffer-new-shared
Open

feat: add ArrayBuffer::from_raw_parts and from_raw_parts_shared for external buffers#683
richarddd wants to merge 2 commits intoDelSkayn:masterfrom
richarddd:feat/array-buffer-new-shared

Conversation

@richarddd
Copy link
Copy Markdown
Collaborator

Issue

N/A

Description of changes

Adds ArrayBuffer::from_raw_parts (plain ArrayBuffer) and ArrayBuffer::from_raw_parts_shared (SharedArrayBuffer) for wrapping caller-owned memory with a custom JSFreeArrayBufferDataFunc, enabling zero-copy exposure of Rust-owned byte storage (Arc<[u8]>, bytes::Bytes, memory maps, …) to JS; drop_fn is invoked synchronously on construction failure so the caller's buffer is released exactly once.

Checklist

  • Added change to the changelog
  • Created unit tests for my feature if needed

@richarddd richarddd force-pushed the feat/array-buffer-new-shared branch from 30d0b0e to 5a27282 Compare April 27, 2026 14:05
Comment thread core/src/value/array_buffer.rs Outdated
@richarddd richarddd force-pushed the feat/array-buffer-new-shared branch 3 times, most recently from 810e2f3 to 6794302 Compare April 29, 2026 20:04
…external-buffer constructors with mutable, shared, and immutable variants
@richarddd richarddd force-pushed the feat/array-buffer-new-shared branch from 6794302 to 9bcc1a0 Compare April 29, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants