pub struct Source {
pub stdout_buffer: [u8; 4096],
pub stderr_buffer: [u8; 4096],
pub buffered_stream_backing: QuietWriterAdapter,
pub buffered_error_stream_backing: QuietWriterAdapter,
pub stream_backing: QuietWriterAdapter,
pub error_stream_backing: QuietWriterAdapter,
pub raw_stream: File,
pub raw_error_stream: File,
pub out_buffer: *mut [u8],
pub err_buffer: *mut [u8],
/* private fields */
}Fields§
§stdout_buffer: [u8; 4096]§stderr_buffer: [u8; 4096]§buffered_stream_backing: QuietWriterAdapter§buffered_error_stream_backing: QuietWriterAdapter§stream_backing: QuietWriterAdapter§error_stream_backing: QuietWriterAdapter§raw_stream: File§raw_error_stream: File§out_buffer: *mut [u8]§err_buffer: *mut [u8]Implementations§
Source§impl Source
impl Source
pub const ZEROED: Source
Sourcepub fn buffered_stream(&mut self) -> &mut Writer
pub fn buffered_stream(&mut self) -> &mut Writer
Accessors replacing the self-referential *std.Io.Writer fields.
pub fn buffered_error_stream(&mut self) -> &mut Writer
pub fn stream(&mut self) -> &mut Writer
pub fn error_stream(&mut self) -> &mut Writer
pub fn init(out: &mut Source, stream: File, err_stream: File)
pub fn configure_thread()
pub fn configure_named_thread(name: &ZStr)
Sourcepub fn configure_thread_no_js()
pub fn configure_thread_no_js()
Like [configure_thread] but skips the JSC StackCheck FFI call
(Bun__StackCheck__initialize → WTF::StackBounds::currentThreadStackBoundsInternal).
Use on pure-Rust worker threads (ThreadPool workers, HTTP client,
watchers) that never execute JavaScript. On the bun install cold path
the WTF/JSC .text pages backing those C++ symbols sit ~6 pages across
three otherwise-untouched 64 KB blocks; faulting them in from every
worker is pure overhead when no JS will ever run on that thread.
Threads that may run JS (web workers, debugger, the main VM thread)
must keep using [configure_thread] / [configure_named_thread].
Sourcepub fn configure_named_thread_no_js(name: &ZStr)
pub fn configure_named_thread_no_js(name: &ZStr)
Named variant of [configure_thread_no_js].
Sourcepub fn ensure_thread_source()
pub fn ensure_thread_source()
Idempotent per-thread output bring-up for JS sink paths (console.*,
process.stdout.write). Adopts the global stream slots on the current
thread, publishing them from the real stdio fds on first use in the
process. Unlike init_test it does NOT force colours off (safe for
late bring-up on worker threads of an already-initialized CLI), and
unlike Source::configure_thread it does not touch the JS
StackCheck FFI — a console write never executes JavaScript.