Skip to main content

RawBuf

Struct RawBuf 

Source
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

Source

pub fn empty() -> Self

A zero-length buffer not backed by any arena.

Source

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.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

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.

Source

pub fn as_mut_slice<T: Pod>(&mut self) -> &mut [T]

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.