silk.platform.windows.console.
Windows standard-output and standard-error writes without a C runtime.
When to use#
Provide WindowsConsole.stdout or WindowsConsole.stderr for Writer. Runtime reports also
use WindowsConsole.writeAll, with selector 1 for standard output or 2 for standard error.
Import as WindowsConsole with import silk.platform.windows.console { WindowsConsole }.
Public declarations: 1.
WindowsConsole#
pub struct WindowsConsoleAn unbuffered Writer for a Windows standard handle, without ownership of that handle.
Details#
Redirection writes bytes unchanged with WriteFile. A real console receives UTF-16 through
WriteConsoleW, independent of its output code page. Each console write requires complete canonical
WTF-8 bytes; malformed or incomplete input fails. Lone surrogates are passed as UTF-16 code units.
Flush does nothing. Writes have no inter-thread message lock and can make partial progress before failure.
Implementation WindowsConsole#
impl WindowsConsoleAssociated function enableAnsi#
pub effect fn enableAnsi(selector: i32) -> boolEnables ANSI escape processing on standard output (1) or standard error (2).
Details#
Returns false for another selector, a redirected or invalid handle, or an OS refusal. Existing mode bits are preserved. The successful setting persists on the console handle.
Associated function stdout#
pub fn stdout() -> WindowsConsoleReturns an unbuffered standard-output writer. It does not read or change the process handle.
Associated function stderr#
pub fn stderr() -> WindowsConsoleReturns an unbuffered standard-error writer. It does not read or change the process handle.
Associated function writeAllGather#
pub effect fn writeAllGather(selector: i32, prefix: &[u8], rest: &[&[u8]], error: &mut i32) -> boolWrites prefix followed by every slice in rest to standard handle 1 or 2.
Details#
Redirected output preserves arbitrary bytes. Console output decodes the concatenation as
canonical WTF-8, including characters split across slices, without allocating. Calls can
interleave with other threads and can write a prefix before failure. Empty input succeeds.
Success sets error to zero; failure sets a Windows error, 6 for an invalid selector,
1113 for invalid WTF-8, or 29 for invalid progress. No handle is closed.
Associated function writeAll#
pub effect fn writeAll(selector: i32, bytes: &[u8], error: &mut i32) -> boolWrites all bytes to standard handle 1 or 2, and returns whether all writes succeeded.
Details#
Redirection preserves bytes. A real console receives decoded UTF-16 without a code-page change.
Each real-console call requires complete canonical WTF-8. The operation does not allocate or close handles.
On failure, error receives the Windows error, 6 for an invalid selector, 1113 for invalid
WTF-8, or 29 for zero or invalid progress. Successful calls set error to zero.
Gotchas#
Some output can precede a failure. Concurrent writes can interleave. Empty input makes no host call.
Implementation Writer for WindowsConsole#
impl Writer for WindowsConsoleOperation writeAll#
effect fn writeAll(self: &mut Self, bytes: &[u8]) -> () ! WriterError ? &mut WriterOperation flush#
effect fn flush(self: &mut Self) -> () ! WriterError ? &mut WriterOperation writeVectored#
effect fn writeVectored(self: &mut Self, bytes: &[&[u8]]) -> () ! WriterError ? &mut WriterCategory: Windows platform.
Profiles: x86_64-pc-windows-msvc.