Deserialize a Name component using a lookup table for parents.
( buf: &mut &[u8], names: &FxHashMap<Address, Name>, )
| 980 | /// Deserialize a non-Muts ConstantInfo (Muts is handled separately with FLAG_MUTS) |
| 981 | pub fn get(variant: u64, buf: &mut &[u8]) -> Result<Self, String> { |
| 982 | match variant { |
| 983 | Self::CONST_DEFN => Ok(Self::Defn(Definition::get(buf)?)), |
| 984 | Self::CONST_RECR => Ok(Self::Recr(Recursor::get(buf)?)), |
| 985 | Self::CONST_AXIO => Ok(Self::Axio(Axiom::get(buf)?)), |
| 986 | Self::CONST_QUOT => Ok(Self::Quot(Quotient::get(buf)?)), |
| 987 | Self::CONST_CPRJ => Ok(Self::CPrj(ConstructorProj::get(buf)?)), |
| 988 | Self::CONST_RPRJ => Ok(Self::RPrj(RecursorProj::get(buf)?)), |
| 989 | Self::CONST_IPRJ => Ok(Self::IPrj(InductiveProj::get(buf)?)), |
| 990 | Self::CONST_DPRJ => Ok(Self::DPrj(DefinitionProj::get(buf)?)), |
| 991 | x => Err(format!("ConstantInfo::get: invalid variant {x}")), |
| 992 | } |
| 993 | } |
| 994 | } |
| 995 | |
| 996 | fn put_refs(refs: &[Address], buf: &mut Vec<u8>) { |
| 997 | put_u64(refs.len() as u64, buf); |
| 998 | for r in refs { |
| 999 | put_address(r, buf); |
| 1000 | } |
| 1001 | } |
| 1002 | |
| 1003 | fn get_refs(buf: &mut &[u8]) -> Result<Vec<Address>, String> { |
| 1004 | let num = get_u64(buf)?; |
| 1005 | let mut refs = Vec::with_capacity(capped_capacity(num, buf)); |
| 1006 | for _ in 0..num { |
| 1007 | refs.push(get_address(buf)?); |
| 1008 | } |
| 1009 | Ok(refs) |
| 1010 | } |
| 1011 | |
| 1012 | fn put_univs(univs: &[Arc<Univ>], buf: &mut Vec<u8>) { |
| 1013 | put_u64(univs.len() as u64, buf); |
| 1014 | for u in univs { |
| 1015 | put_univ(u, buf); |
| 1016 | } |
| 1017 | } |
| 1018 | |
| 1019 | fn get_univs(buf: &mut &[u8]) -> Result<Vec<Arc<Univ>>, String> { |
| 1020 | let num = get_u64(buf)?; |
| 1021 | let mut univs = Vec::with_capacity(capped_capacity(num, buf)); |
| 1022 | for _ in 0..num { |
| 1023 | univs.push(get_univ(buf)?); |
| 1024 | } |
| 1025 | Ok(univs) |
| 1026 | } |
| 1027 | |
| 1028 | impl Constant { |
| 1029 | pub fn put(&self, buf: &mut Vec<u8>) { |
| 1030 | match &self.info { |
no test coverage detected