# `nupp.text.buffer.types` ## Types ### `Buffer` _record_ ```nupp 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` ```nupp __len: function(self): integer ``` Returns the unread byte count without consuming data. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | ###### Returns | Type | Description | | --- | --- | | `integer` | | ##### `__concat` ```nupp __concat: function(self, other: any): string ``` Concatenates the buffer's unread text with another value. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | | `other` | `any` | | ###### Returns | Type | Description | | --- | --- | | `string` | | ##### `__tostring` ```nupp __tostring: function(self): string ``` Returns unread bytes without consuming them. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | ###### Returns | Type | Description | | --- | --- | | `string` | | ##### `put` ```nupp put: function(exclusive b: Buffer, ...: any): Buffer borrows (b) ``` Appends each value and returns a borrow of this same buffer for chaining. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `exclusive b` | `Buffer` | | | `...` | `any` | | ###### Returns | Type | Description | | --- | --- | | `Buffer borrows (b)` | | ##### `putf` ```nupp putf: function(exclusive b: Buffer, fmt: string, ...: any): Buffer borrows (b) ``` Formats and appends text, returning the same borrowed buffer. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `exclusive b` | `Buffer` | | | `fmt` | `string` | | | `...` | `any` | | ###### Returns | Type | Description | | --- | --- | | `Buffer borrows (b)` | | ##### `get` ```nupp 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 | Name | Type | Description | | --- | --- | --- | | `exclusive b` | `Buffer` | | | `...` | `integer?` | | ###### Returns | Type | Description | | --- | --- | | `string` | | ##### `tostring` ```nupp tostring: function(b: Buffer): string ``` Copies unread bytes into a string without advancing the FIFO. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `b` | `Buffer` | | ###### Returns | Type | Description | | --- | --- | | `string` | | ##### `reset` ```nupp reset: function(exclusive b: Buffer): Buffer borrows (b) ``` Discards buffered bytes and returns the same reusable buffer. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `exclusive b` | `Buffer` | | ###### Returns | Type | Description | | --- | --- | | `Buffer borrows (b)` | | ##### `free` ```nupp free: function(exclusive b: Buffer): Buffer borrows (b) ``` Releases retained storage and returns the same reusable buffer. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `exclusive b` | `Buffer` | | ###### Returns | Type | Description | | --- | --- | | `Buffer borrows (b)` | | ##### `skip` ```nupp skip: function(exclusive b: Buffer, count: integer): Buffer borrows (b) ``` Discards a prefix of unread bytes and returns the same borrowed buffer. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `exclusive b` | `Buffer` | | | `count` | `integer` | | ###### Returns | Type | Description | | --- | --- | | `Buffer borrows (b)` | | ##### `set` ```nupp set: function(exclusive b: Buffer, bytes: string): Buffer borrows (b) ``` Replaces unread contents with bytes and returns the same borrowed buffer. ###### Arguments | Name | Type | Description | | --- | --- | --- | | `exclusive b` | `Buffer` | | | `bytes` | `string` | | ###### Returns | Type | Description | | --- | --- | | `Buffer borrows (b)` | |