⌂ Modules Module: nupp Module: nupp.span Module: nupp.span
Bounds-carrying borrowed pointer views.
ByteSpan keeps a runtime element count beside a rooted pointer. Indexing and slicing check that count before the only unsafe pointer operations in this module. Public code never has to dereference or offset a raw pointer.
Module contents Types Type Kind Description ByteSpanrecord A checked, shared view over contiguous elements. ByteWriteSpanrecord An affine checked write range.
Functions Function Kind Description ByteSpan:getmethod Returns one byte after checking the one-based index. ByteSpan:slicemethod Returns a checked subspan, inclusive at both ends. from_carrayfunction Creates a checked shared span over a C array and an explicit logical count. from_stringfunction Creates a byte span over a Lua string and keeps that string rooted. write_carrayfunction Creates an affine write span.
Types
ByteSpanrecord
A checked, shared view over contiguous elements.
local record ByteSpan
readonly anchor : any
readonly pointer : uint8 [ ? ] borrows anchor
readonly offset : integer
readonly count : integer
end
Fields Name Type Description anchorany pointeruint8 [ ? ] borrows anchor offsetinteger countinteger
ByteWriteSpanrecord
An affine checked write range. Its live token keeps the source under an incompatible-borrow barrier until commit or scope exit consumes it.
Methods
set
set : function set ( self : ByteWriteSpan , index : integer , value : uint8 ) : nil
Arguments
Returns
Fields Name Type Description anchorany pointeruint8 [ ? ] borrows anchor offsetinteger countinteger
Functions
ByteSpan:getmethod
Returns one byte after checking the one-based index.
function ByteSpan : get ( index : integer ) : uint8
Arguments Name Type Description indexinteger
Returns
Raises
ByteSpan:slicemethod
Returns a checked subspan, inclusive at both ends.
function ByteSpan : slice ( first : integer , last : integer ? ) : ByteSpan borrows self
Arguments Name Type Description firstinteger lastinteger ?
Returns
Raises
span.from_carrayfunction
Creates a checked shared span over a C array and an explicit logical count.
Arguments Name Type Description sourceuint8 [ ? ] countinteger
Returns
Raises
span.from_stringfunction
Creates a byte span over a Lua string and keeps that string rooted.
Arguments Name Type Description sourcestring
Returns
span.write_carrayfunction
Creates an affine write span. The source is exclusive during construction and the returned dependent owner prevents invalidating operations until it is committed.
Arguments Name Type Description sourceuint8 [ ? ] countinteger
Returns
Raises
← Previous Module: nupp.resources Next → Module: nupp.suspension