MCPcopy Create free account
hub / github.com/argumentcomputer/ix / decode

Method decode

crates/ffi/src/compile.rs:1210–1252  ·  view source on GitHub ↗

Decode a Lean Ixon.SerializeError to a Rust SerializeError.

(&self)

Source from the content-addressed store, hash-verified

1208 ctor.set_obj(0, build_lean_string(expected));
1209 ctor
1210 },
1211 SerializeError::InvalidTag { tag, context } => {
1212 let ctor = LeanIxSerializeError::alloc(1);
1213 ctor.set_obj(0, build_lean_string(context));
1214 ctor.set_num_8(0, *tag);
1215 ctor
1216 },
1217 SerializeError::InvalidFlag { flag, context } => {
1218 let ctor = LeanIxSerializeError::alloc(2);
1219 ctor.set_obj(0, build_lean_string(context));
1220 ctor.set_num_8(0, *flag);
1221 ctor
1222 },
1223 SerializeError::InvalidVariant { variant, context } => {
1224 let ctor = LeanIxSerializeError::alloc(3);
1225 ctor.set_obj(0, build_lean_string(context));
1226 ctor.set_num_64(0, *variant);
1227 ctor
1228 },
1229 SerializeError::InvalidBool { value } => {
1230 let ctor = LeanIxSerializeError::alloc(4);
1231 ctor.set_num_8(0, *value);
1232 ctor
1233 },
1234 SerializeError::AddressError => Self::new(LeanOwned::box_usize(5)),
1235 SerializeError::InvalidShareIndex { idx, max } => {
1236 let ctor = LeanIxSerializeError::alloc(6);
1237 ctor.set_obj(0, build_lean_nat_usize(*max));
1238 ctor.set_num_64(0, *idx);
1239 ctor
1240 },
1241 }
1242 }
1243}
1244
1245impl<R: LeanRef> LeanIxSerializeError<R> {
1246 /// Decode a Lean Ixon.SerializeError to a Rust SerializeError.
1247 pub fn decode(&self) -> SerializeError {
1248 // Tag 5 (addressError) has 0 fields → Lean represents as scalar
1249 if self.inner().is_scalar() {
1250 let tag = self.inner().unbox_usize();
1251 assert_eq!(tag, 5, "Invalid scalar SerializeError tag: {}", tag);
1252 return SerializeError::AddressError;
1253 }
1254 match self.as_ctor().tag() {
1255 0 => {

Callers 5

rs_roundtrip_raw_envFunction · 0.45
rs_decompile_envFunction · 0.45

Calls 1

tagMethod · 0.80

Tested by

no test coverage detected