pub struct LexBuffer { /* private fields */ }Expand description
Growable byte buffer used by the lexer for token text accumulation.
Corresponds to Mbuffer in lzio.h. The C struct tracked buffer,
n (used length), and buffsize (allocated capacity) as three separate
fields with manual realloc. In Rust all three are implicit in Vec<u8>.
§C mapping (types.tsv)
Mbuffer → LexBuffer
.buffer → Vec<u8> (heap storage)
.n → Vec::len()
.buffsize → Vec::capacity()Implementations§
Source§impl LexBuffer
impl LexBuffer
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Return the buffer contents as a mutable byte slice.
Sourcepub fn truncate_by(&mut self, i: usize)
pub fn truncate_by(&mut self, i: usize)
Shorten the live contents by i bytes without releasing capacity.
Sourcepub fn resize(
&mut self,
_state: &mut LuaState,
size: usize,
) -> Result<(), LuaError>
pub fn resize( &mut self, _state: &mut LuaState, size: usize, ) -> Result<(), LuaError>
Resize the buffer to exactly size bytes, filling new bytes with 0.
Returns Err(LuaError::Memory) on allocation failure.
PORT NOTE: the C macro routes through luaM_reallocvchar and Lua’s
custom allocator. Phase A uses Vec::resize with Rust’s global
allocator; OOM propagation via the custom allocator is a Phase D concern.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LexBuffer
impl RefUnwindSafe for LexBuffer
impl Send for LexBuffer
impl Sync for LexBuffer
impl Unpin for LexBuffer
impl UnsafeUnpin for LexBuffer
impl UnwindSafe for LexBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more