ReleaseToken class

PR #5: stable handle for a buffer the Rust pool owns. The Dart side can hand the underlying Uint8List directly to a texture (no copy), and when the parent ReleaseToken becomes unreachable, a Finalizer returns the buffer to the Rust pool via bufferPoolReleaseByToken.

Why a token? The Rust buffer pool is a single shared best-fit free list, so a "raw pointer" would be ambiguous — the same Vec<u8> could be sitting in the pool or in someone else's hand. A monotonically increasing token gives the Rust side a stable identifier for telemetry and lets the Finalizer fire-and-forget (the token is opaque to Dart, so there's no risk of a misuse causing a wrong-pointer write).

Use via ReleaseToken.fromBytes or ReleaseToken.fromPreview.

Constructors

ReleaseToken.fromBytes({required Uint8List bytes, required BigInt token})
Build a ReleaseToken from a Uint8List + token. Prefer fromPreview in real code; this constructor exists for tests and for cases where the buffer comes from a non-preview path.
factory
ReleaseToken.fromPreview(PreviewFrameRgbaBuf frame)
Build a ReleaseToken from a PreviewFrameRgbaBuf. The rgba field's underlying buffer is the Rust-owned data, so we hand it to the Finalizer directly.
factory

Properties

bytes Uint8List
Underlying buffer (zero-copy view into the Rust-owned data).
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
token BigInt
no setter

Methods

detach() → void
Drop the token without releasing the buffer. After this, the buffer will be returned to the pool by the next call to bufferPoolRelease / bufferPoolReleaseByToken from the app, or when Rust drops its reference. Use when you want to keep the buffer alive past the ReleaseToken's lifetime (e.g. hand it to a worker isolate).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited