pub struct Inspector {
pub styled: bool,
/* private fields */
}Expand description
Renders JS values the way util.inspect does, with or without colour.
Fields§
§styled: boolWhether rendered values carry SGR colour codes.
Implementations§
Source§impl Inspector
impl Inspector
pub fn new(styled: bool) -> Self
pub fn with_depth(self, max_depth: usize) -> Self
Sourcepub fn paint(self, out: &mut String, code: &str, text: &str)
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.
Sourcepub fn punct(out: &mut String, text: &str)
pub fn punct(out: &mut String, text: &str)
Structural punctuation we emit ourselves — never sanitised, never styled.
Sourcepub fn printf(
self,
out: &mut String,
fmt: &str,
args: &[Value<'_>],
) -> Result<usize>
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).
Sourcepub fn args(self, out: &mut String, args: &[Value<'_>]) -> Result<()>
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.
Sourcepub fn value(
self,
out: &mut String,
value: &Value<'_>,
depth: usize,
) -> Result<()>
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.
Sourcepub fn special_object(
self,
out: &mut String,
object: &Object<'_>,
depth: usize,
) -> Result<bool>
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§
Auto Trait Implementations§
impl Freeze for Inspector
impl RefUnwindSafe for Inspector
impl Send for Inspector
impl Sync for Inspector
impl Unpin for Inspector
impl UnsafeUnpin for Inspector
impl UnwindSafe for Inspector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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