Skip to main content

Inspector

Struct Inspector 

Source
pub struct Inspector {
    pub styled: bool,
    /* private fields */
}
Expand description

Renders JS values the way util.inspect does, with or without colour.

Fields§

§styled: bool

Whether rendered values carry SGR colour codes.

Implementations§

Source§

impl Inspector

Source

pub fn new(styled: bool) -> Self

Source

pub fn with_depth(self, max_depth: usize) -> Self

Source

pub fn quoted(self) -> Self

Quote strings even at the top level, the way util.inspect does.

Source

pub fn paint(self, out: &mut String, code: &str, text: &str)

Write text (already-formatted, JS-derived) under code, sanitising any escape sequence the value itself carried.

Source

pub fn punct(out: &mut String, text: &str)

Structural punctuation we emit ourselves — never sanitised, never styled.

Source

pub fn printf( self, out: &mut String, fmt: &str, args: &[Value<'_>], ) -> Result<usize>

Node’s util.format core: when the first argument is a string, %s / %d / %i / %f / %j / %o / %O / %c / %% consume the following arguments; leftovers are appended space-separated. Returns how many arguments were consumed (including the format string itself).

Source

pub fn args(self, out: &mut String, args: &[Value<'_>]) -> Result<()>

Render a whole console.* argument list: a leading format string consumes what it needs, the rest is appended space-separated.

Source

pub fn value( self, out: &mut String, value: &Value<'_>, depth: usize, ) -> Result<()>

Node-ish console value renderer: top-level strings unquoted (quoted with ' inside containers, like util.inspect), arrays as [ 1, 2 ], objects as { a: 1, b: 2 }, Map(n) { k => v }, Set(n) { v }, Dates as ISO strings, RegExp as /src/flags, [Function: name], Symbol(desc), 123n bigints, name: message (+ stack) for Error values, and [Array] / [Object] past max_depth nesting.

Source

pub fn special_object( self, out: &mut String, object: &Object<'_>, depth: usize, ) -> Result<bool>

Render Date / RegExp / Map / Set the way Node’s util.inspect does (2026-01-01T00:00:00.000Z, /ab+c/i, Map(1) { 'a' => 1 }, Set(2) { 1, 2 }). Returns false when object is none of those so the caller falls through to plain-object rendering. Detection is by constructor name — cheap, and correct for anything built from the real globals.

Trait Implementations§

Source§

impl Clone for Inspector

Source§

fn clone(&self) -> Inspector

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Inspector

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> AsOut<T> for T
where T: Copy,

Source§

fn as_out(&mut self) -> Out<'_, T>

Returns an out reference to self.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ParallelSend for T
where T: Send,

Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more