pub enum RenderedValue {
Show 13 variants
Int {
bits: u32,
value: i64,
},
Uint {
bits: u32,
value: u64,
},
Bool {
value: bool,
},
Char {
value: u8,
},
Float {
bits: u32,
value: f64,
},
Enum {
bits: u32,
value: i64,
variant: Option<String>,
is_signed: bool,
},
Struct {
type_name: Option<String>,
members: Vec<RenderedMember>,
},
Array {
len: usize,
elements: Vec<RenderedValue>,
},
CpuList {
cpus: String,
},
Ptr {
value: u64,
deref: Option<Box<RenderedValue>>,
deref_skipped_reason: Option<String>,
cast_annotation: Option<Cow<'static, str>>,
},
Bytes {
hex: String,
},
Truncated {
needed: usize,
had: usize,
partial: Box<RenderedValue>,
},
Unsupported {
reason: String,
},
}Expand description
Structured rendering of one BTF-typed value.
The kind tag identifies the variant; field order matches the
rendering pipeline (Int / Uint / Bool / Char before Float / Enum /
Struct / Array / CpuList / Ptr, with Bytes / Truncated / Unsupported
as the recovery path).
Variants§
Int
Signed integer. bits is the BTF-declared width.
Always signed by construction. The internal render_int
routes BTF_KIND_INT with is_signed() = false to
Self::Uint; is_signed() = true to Self::Int. The
variant choice IS the signedness tag — no equivalent of
Enum::is_signed is needed because unsigned ints never land
here.
Uint
Unsigned integer. bits is the BTF-declared width. See the
signedness-by-variant note on Self::Int.
Bool
Boolean (BTF int with is_bool()).
Char
Character (BTF int with is_char()). value holds the raw
byte for round-tripping; non-printable values are preserved.
Field name matches the other scalar variants (Int / Uint / Bool /
Float / Enum / Ptr) so any field-driven serializer treats them
uniformly.
Float
IEEE-754 float (BTF_KIND_FLOAT).
Enum
Enum value with optional resolved variant name.
is_signed tracks the BTF type’s signedness so accessors
downstream can decide whether to reinterpret the bit
pattern (unsigned: value as u64 gives the wire bits back
even when the storage width forces a negative i64) or
treat negative values as out-of-range (signed: a true
negative enum variant is not coercible to u64).
Constructed by the BTF renderer; downstream consumers read
is_signed (or trust the typed accessors like
RenderedValue::as_u64 to dispatch correctly) rather than
building Enum literals directly. #[serde(default)] lets
pre-is_signed archives (test sidecars, captured failure
dumps) deserialize as is_signed: false, the default. Note
that this changes behavior for old archives carrying a
negative value: pre-field RenderedValue::as_u64 returned
None for any negative stored value (whether the BTF type
was signed-negative OR unsigned-with-high-bit-set, since the
renderer never tracked the distinction); post-field, a
deserialize-as-default is_signed: false reinterprets the
bit pattern via as u64. That shift is intentional — old
archives could not encode the signedness, and the conservative
“treat as unsigned bits” recovers more cases than the old
“any negative is rejected” behavior.
Struct
Aggregate (struct or union). For unions, only the first member is meaningful — the renderer emits all members each backed by the same byte range so the caller can pick.
Array
Array. elements is truncated to MAX_ARRAY_ELEMS.
CpuList
CPU bitmask rendered as a range-collapsed list. Produced when
the renderer detects a cpumask, bpf_cpumask, or scx_bitmap
struct by BTF type name.
Field-name exception: scalar variants (Int / Uint / Bool /
Char / Float / Enum / Ptr) name the inner field value for
uniform serialization; CpuList breaks the convention by
using cpus because the rendered text is type-specific
(e.g. "0-2,5") and reads more naturally as cpus in
JSON consumers — value would be misleading for a non-
scalar payload. Char keeps value since its payload is a
single byte (the BTF int type is the underlying scalar).
Ptr
Pointer value with optional dereferenced content. When deref
is Some, the pointer was chased at dump time and the target
struct is rendered inline. deref_skipped_reason carries the
cause when the chase was attempted but did not produce a
deref — None means no chase was attempted (e.g. null
pointer or no MemReader supplied), and a non-None
reason with deref: None means the chase was attempted but
could not complete (cross-page boundary, BTF-size truncated
against the read cap, kernel kptr that failed plausibility
gating, etc.). The reason field enables the consumer to
distinguish “we didn’t try” from “we tried and failed for
reason X” without a separate flag.
cast_annotation distinguishes cast-recovered pointers
(set by render_cast_pointer to "cast→arena" /
"cast→kernel") from BTF-typed pointers (the
[Type::Ptr] arm normally leaves it None). Display
surfaces it as a parenthesised tag so operators can tell
at a glance whether the pointer came from native BTF
typing or the cast analyzer’s recovery path.
One [Type::Ptr] exception: when the renderer recovers a
BTF_KIND_FWD pointee’s real struct id via the sdt_alloc
bridge (MemReader::resolve_arena_type), the arena
branch sets this field to "sdt_alloc" so the rendered
subtree is flagged as a recovered chase rather than a
native BTF resolve. Cast-recovered pointers that cleared
the same bridge extend the annotation to
"cast→{addr_space} (sdt_alloc)".
Storage is Cow<'static, str> so the renderer’s emit
sites — every value the renderer itself produces is one
of a five-element closed set
("sdt_alloc", "cast→arena", "cast→kernel",
"cast→arena (sdt_alloc)", "cast→kernel (sdt_alloc)")
— borrow &'static str literals via Cow::Borrowed
without per-chase heap allocations. JSON deserialization
produces Cow::Owned (serde’s Cow impl forwards
to String’s deserializer), so existing serialized
snapshots round-trip unchanged.
Fields
deref: Option<Box<RenderedValue>>Bytes
Fallback hex dump for types the renderer can decode the size of
but not the structure (e.g. BTF_KIND_FWD). Hex is lowercase,
space-separated.
Truncated
The byte slice ended before the type’s declared size. needed
is the required byte count; had is what was supplied.
partial carries whatever decoded successfully before the
truncation: a Struct with the members that fit (further
truncated members nest as their own Truncated), an
Array with the elements that fit, or a Bytes hex dump of
the raw bytes that were available when no structured partial
applied (e.g. a 2-byte slice for a 4-byte int).
Unsupported
BTF type kind the renderer does not handle (Func, FuncProto,
Fwd, Void, or a kind beyond the qualifier-peel cap).
reason carries the human-readable cause.
Implementations§
Source§impl RenderedValue
impl RenderedValue
Sourcepub fn member(&self, name: &str) -> Option<&RenderedValue>
pub fn member(&self, name: &str) -> Option<&RenderedValue>
Single-step struct-member walk. Returns the named member of a
Struct (or Truncated{partial: Struct}), peeling through
Ptr{deref: Some} transparently. None for any other variant
or when the member name is absent.
Sourcepub fn index(&self, i: usize) -> Option<&RenderedValue>
pub fn index(&self, i: usize) -> Option<&RenderedValue>
Array-element walk by 0-indexed position. Returns the i-th
element of an Array (or Truncated{partial: Array} —
None if i is past what the truncation preserved), peeling
through Ptr{deref: Some}. None for any other variant or
out-of-range index.
Sourcepub fn get(&self, path: &str) -> Option<&RenderedValue>
pub fn get(&self, path: &str) -> Option<&RenderedValue>
Dotted-path walk equivalent to a chain of Self::member
calls split on .. Empty path returns Some(self); any
component that fails to resolve returns None. Peels through
Ptr{deref: Some} and Truncated{partial: Struct} at every
step.
Sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
Coerce a scalar variant to u64. Accepts Uint, Bool
(true=1, false=0), Char (raw byte), and Ptr (numeric
address). Int<0, Enum<0, Float, Struct, Array,
Bytes, Truncated, and Unsupported return None. Peels
Ptr{deref: Some} transparently — the unsigned-pointer
numeric value still wins.
Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Coerce a scalar variant to i64. Accepts Int, Uint<=i64::MAX,
Bool, Char, and Enum. Uint>i64::MAX, Float,
aggregate, and recovery variants return None.
Sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Coerce a scalar variant to f64. Float is the only direct
source; integer variants widen via as f64 (with the usual
precision loss above 2^53).
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Coerce a scalar variant to bool. Direct from Bool; from
Uint/Int/Char/Enum/Ptr returns Some(value != 0) —
a Ptr coerces as a non-null test, matching as_u64’s
treatment of a pointer as its numeric address. Float and
aggregate variants return None.
The Ptr arm keeps this in lockstep with the scalar
SnapshotField::as_bool accessor (scenario/snapshot/field.rs),
which already coerces Ptr to a non-null bool. Without it the
array path (as_bool_array → this method per element) rejected
a pointer element that the scalar accessor accepted, so
field.as_bool() and field.as_bool_array() disagreed on a
pointer — the same scalar-vs-array divergence the Enum
signedness handling in as_u64 was added to eliminate.
Sourcepub fn as_u64_array(&self) -> Option<Vec<u64>>
pub fn as_u64_array(&self) -> Option<Vec<u64>>
Extract a homogeneous Vec<u64> from an Array whose every
element coerces via Self::as_u64. Returns None if self
is not an Array (or Truncated{partial: Array}), or if any
element fails the coercion — the caller cannot rely on a
partial result. Peels Ptr{deref: Some}.
Sourcepub fn as_u32_array(&self) -> Option<Vec<u32>>
pub fn as_u32_array(&self) -> Option<Vec<u32>>
Extract a homogeneous Vec<u32> from an Array whose every
element coerces via Self::as_u64 and fits in u32.
Out-of-range values return None (no silent truncation).
Sourcepub fn as_i64_array(&self) -> Option<Vec<i64>>
pub fn as_i64_array(&self) -> Option<Vec<i64>>
Extract a homogeneous Vec<i64> from an Array whose every
element coerces via Self::as_i64.
Sourcepub fn as_f64_array(&self) -> Option<Vec<f64>>
pub fn as_f64_array(&self) -> Option<Vec<f64>>
Extract a homogeneous Vec<f64> from an Array whose every
element coerces via Self::as_f64.
Sourcepub fn as_bool_array(&self) -> Option<Vec<bool>>
pub fn as_bool_array(&self) -> Option<Vec<bool>>
Extract a homogeneous Vec<bool> from an Array whose every
element coerces via Self::as_bool.
Trait Implementations§
Source§impl Clone for RenderedValue
impl Clone for RenderedValue
Source§fn clone(&self) -> RenderedValue
fn clone(&self) -> RenderedValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RenderedValue
impl Debug for RenderedValue
Source§impl<'de> Deserialize<'de> for RenderedValue
impl<'de> Deserialize<'de> for RenderedValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for RenderedValue
impl Display for RenderedValue
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Human-readable rendering for test-failure output. JSON remains
the programmatic form (via serde_json); this Display emits
pretty-printed text suitable for assertion failure messages,
e.g.
task_ctx{weight=1024, last_runnable_at=12345678901234}Structs that fit within the inline width budget pack onto one
line as TypeName{field=value, field=value}; wider structs
break to a multi-line TypeName: breadcrumb form with
indented field=value rows. Nested structs and arrays indent
by two spaces per level. Scalar-only arrays render inline
([1, 2, 3]); arrays containing structs / nested arrays
render block-style with one element per line.
Source§impl PartialEq for RenderedValue
impl PartialEq for RenderedValue
Source§impl Serialize for RenderedValue
impl Serialize for RenderedValue
impl StructuralPartialEq for RenderedValue
Auto Trait Implementations§
impl Freeze for RenderedValue
impl RefUnwindSafe for RenderedValue
impl Send for RenderedValue
impl Sync for RenderedValue
impl Unpin for RenderedValue
impl UnwindSafe for RenderedValue
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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