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 + counterChild: [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:Nonewhenframe_id > 99_999(would overflow into the EvalResult band).EvalResult:Nonewhen1_000_000 + counter > EVAL_MAX(counter ≥ 1_999_000_000, practically unreachable, but enforced for type-level correctness).Child:Nonewhenparent < 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
EvalResult
A structured evaluation result reference (HASH or ARRAY from evaluate).
Child
A child variable reference within a parent variable.
Implementations§
Source§impl VariableReference
impl VariableReference
Sourcepub fn encode(&self) -> Option<i32>
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:Nonewhenframe_idis out of[0, 99_999](would bleed into EvalResult band).EvalResult:Nonewhencounteris negative or1_000_000 + counter > 1_999_999_999(would bleed into Child band; requires counter ≥ 1_999_000_000, practically unreachable).Child:Nonewhenparent < 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).
Sourcepub fn decode(raw: i32) -> Option<Self>
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]→Childraw in [1_000_000, 1_999_999_999]→EvalResult{counter: raw - 1_000_000}raw in [1, 999_999]→Scopeifraw % 10 ∈ {1,2,3}, elseNone- 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
impl Clone for VariableReference
Source§fn clone(&self) -> VariableReference
fn clone(&self) -> VariableReference
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for VariableReference
Source§impl Debug for VariableReference
impl Debug for VariableReference
impl Eq for VariableReference
Source§impl PartialEq for VariableReference
impl PartialEq for VariableReference
Source§fn eq(&self, other: &VariableReference) -> bool
fn eq(&self, other: &VariableReference) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for VariableReference
Auto Trait Implementations§
impl Freeze for VariableReference
impl RefUnwindSafe for VariableReference
impl Send for VariableReference
impl Sync for VariableReference
impl Unpin for VariableReference
impl UnsafeUnpin for VariableReference
impl UnwindSafe for VariableReference
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.