Extended buffered-stream helpers for seekable reads, formatted reads, and buffered writes.
- Repository:
opencomputers - System:
openos - Type:
library
OpenComputers/src\main\resources\assets\opencomputers\loot\openos\lib\core\full_buffer.lua
local buffer = require("buffer") -- advanced methods load lazily- Description: Write one string through the configured buffering strategy, flushing first when needed.
- Parameters:
arg: String chunk to append or flush through the wrapped stream.
stream:buffered_write('hello\n')- Description: Read one or more values using Lua-style numeric and
*l/*L/*a/*nformat specifiers. - Parameters:
readChunk: Low-level chunk reader callback used to fill the internal read buffer....: Format specifiers or numeric byte/character counts.
local line = stream:formatted_read(readChunk, '*l')- Description: Return the configured read timeout in seconds, or
nilwhen no timeout is active.
local timeout = stream:getTimeout()- Description: Read until EOF and return all buffered and newly fetched data as one string.
- Parameters:
readChunk: Low-level chunk reader callback.
local body = stream:readAll(readChunk)- Description: Read exactly the requested number of bytes or Unicode characters, depending on binary mode.
- Parameters:
readChunk: Low-level chunk reader callback.n: Requested byte or character count.
local chunk = stream:readBytesOrChars(readChunk, 16)- Description: Skip leading whitespace, then parse and return the next readable numeric token.
- Parameters:
readChunk: Low-level chunk reader callback.
local number = stream:readNumber(readChunk)- Description: Flush pending writes if needed, adjust read buffering state, and seek the wrapped stream.
- Parameters:
whence: Seek mode:set,cur, orend.offset: Integer offset relative to the chosen mode.
stream:seek('set', 0)- Description: Set the buffered stream read timeout in seconds.
- Parameters:
value: Timeout value that will be converted withtonumber.
stream:setTimeout(2)- Description: Return the unread size currently visible through the buffered wrapper, including internal buffered data.
local remaining = stream:size()- Only exported module functions are listed on this page.