FrameBorrowedView class final
A short-lived view over decoded frame bytes.
This type is designed for extremely high-throughput consumers that can
process frames synchronously and want to avoid allocating a fresh Uint8List
per frame.
Lifetime / safety
A FrameBorrowedView may reference internal buffers owned by a framing
driver (e.g. a RingBuffer). In that case, the bytes are only valid until
the next decode/IO step that can overwrite those buffer regions.
Do not store the view beyond the immediate callback. If you need to retain bytes, call toOwnedBytes inside the callback.
NOTE: retaining any Uint8List views derived from this object (for
example, storing first or second) is also unsafe. Those derived views
are not invalidated and may observe mutated bytes later.
The fail-fast guard in this library only protects access through the FrameBorrowedView object after the callback returns.
Constructors
- FrameBorrowedView.borrowedSegments(Uint8List buf1, int off1, int len1, [Uint8List? buf2, int off2 = 0, int len2 = 0])
-
Constructs a borrowed view with one or two segments.
factory
- FrameBorrowedView.owned(Uint8List bytes)
-
Wraps an owned contiguous byte buffer.
factory
Properties
- first → Uint8List
-
First segment view as a
Uint8List.no setter - firstLength → int
-
Length of the first segment.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isBorrowed → bool
-
Whether the view references internal buffers owned by a driver.
final
- isContiguous → bool
-
Whether the frame is contiguous in memory.
no setter
- length → int
-
Total frame length in bytes.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- second → Uint8List
-
Second segment view as a
Uint8List.no setter - secondLength → int
-
Length of the second segment (non-zero only if the frame wraps).
no setter
Methods
-
forEachSegment(
void f(Uint8List buf, int offset, int length)) → void -
Calls
ffor each segment as(buffer, offset, length). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toBytes(
) → Uint8List -
Copies the frame into a fresh contiguous
Uint8List. -
toOwnedBytes(
) → Uint8List - Returns a byte buffer that is safe to retain.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited