RenderedValue

Enum RenderedValue 

Source
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.

Fields

§bits: u32
§value: i64
§

Uint

Unsigned integer. bits is the BTF-declared width. See the signedness-by-variant note on Self::Int.

Fields

§bits: u32
§value: u64
§

Bool

Boolean (BTF int with is_bool()).

Fields

§value: 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.

Fields

§value: u8
§

Float

IEEE-754 float (BTF_KIND_FLOAT).

Fields

§bits: u32
§value: f64
§

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.

Fields

§bits: u32
§value: i64
§variant: Option<String>
§is_signed: bool
§

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.

Fields

§type_name: Option<String>
§

Array

Array. elements is truncated to MAX_ARRAY_ELEMS.

Fields

§len: usize
§elements: Vec<RenderedValue>
§

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).

Fields

§cpus: String
§

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

§value: u64
§deref_skipped_reason: Option<String>
§cast_annotation: Option<Cow<'static, str>>
§

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.

Fields

§

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).

Fields

§needed: usize
§had: usize
§

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.

Fields

§reason: String

Implementations§

Source§

impl RenderedValue

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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}.

Source

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).

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> RenderedValue

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RenderedValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RenderedValue

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for RenderedValue

Source§

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

Source§

fn eq(&self, other: &RenderedValue) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for RenderedValue

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RenderedValue

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<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.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

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

§

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