pub struct RawBuf { /* private fields */ }Expand description
An untyped byte buffer handed out by the arena. Unique: not Clone, so
mutable access cannot alias. The typed accessors are safe because the
arena zeroes blocks at birth and every Pod type tolerates any bit
pattern.
Implementations§
Source§impl RawBuf
impl RawBuf
Sourcepub unsafe fn borrowed(ptr: NonNull<u8>, len: usize) -> Self
pub unsafe fn borrowed(ptr: NonNull<u8>, len: usize) -> Self
A buffer over memory the arena did not hand out and does not own: a column of a registered frame, which is somebody else’s allocation for as long as it stays registered.
This is what makes a scan of borrowed data a scan rather than a copy. A vector built over one of these reads exactly as a vector over arena memory reads, because a buffer was never more than a pointer and a length; what differs is who frees it, and the answer is nobody here. It carries no generation tag, so the use-after-reset assert that guards arena buffers does not fire on it and cannot: the memory has nothing to do with the morsel.
§Safety
ptr must point at len initialized bytes, aligned for every
type the buffer is read as, unwritten and unfreed by anyone for
as long as this buffer and every vector built over it live. The
caller keeps them alive; in the engine that is the frame
registration holding the handle its columns arrived on.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn as_slice<T: Pod>(&self) -> &[T]
pub fn as_slice<T: Pod>(&self) -> &[T]
View the buffer as a typed slice. The element count is the byte
length over the element width; a partial trailing element is
unreachable because allocation sizes come from alloc_of.