Skip to main content

Source

Struct Source 

Source
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

Source

pub const ZEROED: Source

Source

pub fn buffered_stream(&mut self) -> &mut Writer

Accessors replacing the self-referential *std.Io.Writer fields.

Source

pub fn buffered_error_stream(&mut self) -> &mut Writer

Source

pub fn stream(&mut self) -> &mut Writer

Source

pub fn error_stream(&mut self) -> &mut Writer

Source

pub fn init(out: &mut Source, stream: File, err_stream: File)

Source

pub fn configure_thread()

Source

pub fn configure_named_thread(name: &ZStr)

Source

pub fn configure_thread_no_js()

Like [configure_thread] but skips the JSC StackCheck FFI call (Bun__StackCheck__initializeWTF::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].

Source

pub fn configure_named_thread_no_js(name: &ZStr)

Named variant of [configure_thread_no_js].

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.

Source

pub fn is_no_color() -> bool

Source

pub fn get_force_color_depth() -> Option<ColorDepth>

Source

pub fn is_force_color() -> bool

Source

pub fn color_depth() -> ColorDepth

Source

pub fn set_init(stdout: File, stderr: File)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V