Skip to main content

VariableReference

Enum VariableReference 

Source
pub enum VariableReference {
    Scope {
        frame_id: i32,
        kind: ScopeKind,
    },
    EvalResult {
        counter: i32,
    },
    Child {
        parent: i32,
        index: u32,
    },
}
Expand description

A typed, codec-backed reference into the DAP variablesReference wire space.

§Wire ranges (pairwise disjoint)

  • Scope: [1, 999_999] — frame_id * 10 + kind (frame_id ∈ [0, 99_999], kind ∈ [1,3])
  • EvalResult: [1_000_000, 1_999_999_999] — 1_000_000 + counter
  • Child: [2_000_000_000, i32::MAX] — 2_000_000_000 + (parent << 16 | index)

Wire value 0 is reserved/invalid (DAP: 0 = “no children”). Negative values are invalid. Values in [1_000_000..2_000_000_000) not matching any band decode to None.

§Encode contract

encode() returns None when encoding would bleed a wire value into another variant’s band:

  • Scope: None when frame_id > 99_999 (would overflow into the EvalResult band).
  • EvalResult: None when 1_000_000 + counter > EVAL_MAX (counter ≥ 1_999_000_000, practically unreachable, but enforced for type-level correctness).
  • Child: None when parent < 0 (negative parent produces wire in the EvalResult band, violating the disjoint-band invariant; saturating arithmetic for non-negative inputs).

All fields are primitive scalar types, so VariableReference is Copy.

Variants§

§

Scope

A scope reference: variables in kind scope at stack frame frame_id.

Valid range: frame_id ∈ [0, 99_999].

Fields

§frame_id: i32

Stack frame identifier (0-based; must be ≤ 99_999 for a valid wire encoding).

§kind: ScopeKind

Which scope within the frame.

§

EvalResult

A structured evaluation result reference (HASH or ARRAY from evaluate).

Fields

§counter: i32

Monotonically increasing counter allocated per evaluation result.

§

Child

A child variable reference within a parent variable.

Fields

§parent: i32

The parent variable reference (the Scope or EvalResult that owns this child).

Must be a non-negative, previously encoded variablesReference (always ≥ 0 by the DAP spec). Negative values are invalid and encode() returns None.

§index: u32

Zero-based index of the child within the parent’s variable list.

Implementations§

Source§

impl VariableReference

Source

pub fn encode(&self) -> Option<i32>

Encode this reference to an i32 wire value.

Returns None when encoding would produce a wire value outside the variant’s band:

  • Scope: None when frame_id is out of [0, 99_999] (would bleed into EvalResult band).
  • EvalResult: None when counter is negative or 1_000_000 + counter > 1_999_999_999 (would bleed into Child band; requires counter ≥ 1_999_000_000, practically unreachable).
  • Child: None when parent < 0 (negative parent is semantically invalid — a DAP variablesReference is always non-negative, and negative parents produce wire values in the EvalResult band, corrupting the disjoint-band invariant).
Source

pub fn decode(raw: i32) -> Option<Self>

Decode a wire i32 value into a VariableReference.

Uses pure-range classification against the three disjoint bands:

  • raw in [2_000_000_000, i32::MAX]Child
  • raw in [1_000_000, 1_999_999_999]EvalResult{counter: raw - 1_000_000}
  • raw in [1, 999_999]Scope if raw % 10 ∈ {1,2,3}, else None
  • All others (0, negative, gaps) → None

Because the bands are pairwise disjoint, no value can match more than one case. There is no residue-based disambiguation between bands.

Trait Implementations§

Source§

impl Clone for VariableReference

Source§

fn clone(&self) -> VariableReference

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 VariableReference

Source§

impl Debug for VariableReference

Source§

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

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

impl Eq for VariableReference

Source§

impl PartialEq for VariableReference

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for VariableReference

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = 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.
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