MCPcopy Create free account
hub / github.com/SeaQL/FireDBG.for.Rust / prim_v

Method prim_v

debugger/src/reader.rs:86–119  ·  view source on GitHub ↗
(&self, ty: &str, b: &[u8])

Source from the content-addressed store, hash-verified

84 }
85
86 fn prim_v(&self, ty: &str, b: &[u8]) -> RValue {
87 RValue::Prim(match ty {
88 "bool" => PValue::bool(b[0] != 0),
89 "char" => PValue::char(
90 match char::from_u32(u32::from_ne_bytes(b[..].try_into().unwrap())) {
91 Some(c) => c,
92 None => return RValue::Opaque,
93 },
94 ),
95 "u8" => PValue::u8(u8::from_ne_bytes(b[..].try_into().unwrap())),
96 "i8" => PValue::i8(i8::from_ne_bytes(b[..].try_into().unwrap())),
97 "u16" => PValue::u16(u16::from_ne_bytes(b[..].try_into().unwrap())),
98 "i16" => PValue::i16(i16::from_ne_bytes(b[..].try_into().unwrap())),
99 "u32" => PValue::u32(u32::from_ne_bytes(b[..].try_into().unwrap())),
100 "i32" => PValue::i32(i32::from_ne_bytes(b[..].try_into().unwrap())),
101 "u64" => PValue::u64(u64::from_ne_bytes(b[..].try_into().unwrap())),
102 "i64" => PValue::i64(i64::from_ne_bytes(b[..].try_into().unwrap())),
103 "usize" => PValue::usize(match b.len() {
104 4 => u32::from_ne_bytes(b[..].try_into().unwrap()) as u64,
105 8 => u64::from_ne_bytes(b[..].try_into().unwrap()),
106 _ => panic!("Not a usize: {b:?}"),
107 }),
108 "isize" => PValue::isize(match b.len() {
109 4 => i32::from_ne_bytes(b[..].try_into().unwrap()) as i64,
110 8 => i64::from_ne_bytes(b[..].try_into().unwrap()),
111 _ => panic!("Not a isize: {b:?}"),
112 }),
113 "u128" => PValue::u128(u128::from_ne_bytes(b[..].try_into().unwrap())),
114 "i128" => PValue::i128(i128::from_ne_bytes(b[..].try_into().unwrap())),
115 "f32" => PValue::f32(f32::from_ne_bytes(b[..].try_into().unwrap())),
116 "f64" => PValue::f64(f64::from_ne_bytes(b[..].try_into().unwrap())),
117 _ => panic!("unknown ty `{ty}`"),
118 })
119 }
120
121 fn bytes_v(&self, ty: &str, val: Bytes) -> RValue {
122 RValue::Bytes {

Callers 1

read_valuesMethod · 0.45

Calls 15

boolFunction · 0.85
u8Function · 0.50
i8Function · 0.50
u16Function · 0.50
i16Function · 0.50
u32Function · 0.50
i32Function · 0.50
u64Function · 0.50
i64Function · 0.50
usizeFunction · 0.50
isizeFunction · 0.50
u128Function · 0.50

Tested by

no test coverage detected