#[unsafe(no_mangle)]pub unsafe extern "C" fn patch_seq_read_n(stack: Stack) -> StackExpand description
Read exactly N bytes from stdin
Returns the bytes read and a status flag:
- ( string 1 ) on success (read all N bytes)
- ( string 0 ) at EOF, partial read, or error (string may be shorter than N)
Stack effect: ( Int – String Int )
Like io.read-line+, this returns a result pattern (value + status) to allow
explicit EOF detection. The function name omits the + suffix for brevity
since byte-count reads are inherently status-oriented.
Errors are values, not crashes.
This is used for protocols like LSP where message bodies are byte-counted and don’t have trailing newlines.
§UTF-8 Handling
The bytes are interpreted as UTF-8. Invalid UTF-8 sequences are replaced with the Unicode replacement character (U+FFFD). This is appropriate for text-based protocols like LSP but may not be suitable for binary data.
§Safety
Stack must have an Int on top. The integer must be non-negative and not exceed READ_N_MAX_BYTES (10MB).