nupp.text.buffer.types

Module contents

Types

TypeKindDescription
BufferrecordA mutable FIFO byte sequence shared by all portable buffer providers.

Types#

Bufferrecord#

record Buffer
    metamethod __len: function(self): integer
    metamethod __concat: function(self, other: any): string
    metamethod __tostring: function(self): string
    put: function(exclusive b: Buffer, ...: any): Buffer borrows (b)
    putf: function(exclusive b: Buffer, fmt: string, ...: any): Buffer borrows (b)
    get: function(exclusive b: Buffer, ...: integer?): (string,...string)
    tostring: function(b: Buffer): string
    reset: function(exclusive b: Buffer): Buffer borrows (b)
    free: function(exclusive b: Buffer): Buffer borrows (b)
    skip: function(exclusive b: Buffer, count: integer): Buffer borrows (b)
    set: function(exclusive b: Buffer, bytes: string): Buffer borrows (b)
end

A mutable FIFO byte sequence shared by all portable buffer providers.

Providers return this one nominal declaration rather than defining their own Buffer type. Mutating methods require exclusive access; chaining returns a borrow of the same buffer and must not create another owner. Strings copied out of a buffer are independent of its subsequent mutation or release.

This portable contract contains FIFO and formatting operations. Native pointer access and host serialization belong to the native string.buffer surface.

Methods

__len#
__len: function(self): integer

Returns the unread byte count without consuming data.

Arguments
NameTypeDescription
?self
Returns
TypeDescription
integer
__concat#
__concat: function(self, other: any): string

Concatenates the buffer's unread text with another value.

Arguments
NameTypeDescription
?self
otherany
Returns
TypeDescription
string
__tostring#
__tostring: function(self): string

Returns unread bytes without consuming them.

Arguments
NameTypeDescription
?self
Returns
TypeDescription
string
put#
put: function(exclusive b: Buffer, ...: any): Buffer borrows (b)

Appends each value and returns a borrow of this same buffer for chaining.

Arguments
NameTypeDescription
exclusive bBuffer
...any
Returns
TypeDescription
Buffer borrows (b)
putf#
putf: function(exclusive b: Buffer, fmt: string, ...: any): Buffer borrows (b)

Formats and appends text, returning the same borrowed buffer.

Arguments
NameTypeDescription
exclusive bBuffer
fmtstring
...any
Returns
TypeDescription
Buffer borrows (b)
get#
get: function(exclusive b: Buffer, ...: integer?): (string,...string)

Consumes successive requested byte counts and returns one string per count. With no count, consumes all unread bytes.

Arguments
NameTypeDescription
exclusive bBuffer
...integer?
Returns
TypeDescription
string
tostring#
tostring: function(b: Buffer): string

Copies unread bytes into a string without advancing the FIFO.

Arguments
NameTypeDescription
bBuffer
Returns
TypeDescription
string
reset#
reset: function(exclusive b: Buffer): Buffer borrows (b)

Discards buffered bytes and returns the same reusable buffer.

Arguments
NameTypeDescription
exclusive bBuffer
Returns
TypeDescription
Buffer borrows (b)
free#
free: function(exclusive b: Buffer): Buffer borrows (b)

Releases retained storage and returns the same reusable buffer.

Arguments
NameTypeDescription
exclusive bBuffer
Returns
TypeDescription
Buffer borrows (b)
skip#
skip: function(exclusive b: Buffer, count: integer): Buffer borrows (b)

Discards a prefix of unread bytes and returns the same borrowed buffer.

Arguments
NameTypeDescription
exclusive bBuffer
countinteger
Returns
TypeDescription
Buffer borrows (b)
set#
set: function(exclusive b: Buffer, bytes: string): Buffer borrows (b)

Replaces unread contents with bytes and returns the same borrowed buffer.

Arguments
NameTypeDescription
exclusive bBuffer
bytesstring
Returns
TypeDescription
Buffer borrows (b)