Serialize a Name component (references parent by address). Format: tag (1 byte) + parent_addr (32 bytes) + data
(name: &Name, buf: &mut Vec<u8>)
| 958 | impl ConstantInfo { |
| 959 | /// Serialize a non-Muts ConstantInfo (Muts is handled separately in Constant::put) |
| 960 | pub fn put(&self, buf: &mut Vec<u8>) { |
| 961 | match self { |
| 962 | Self::Defn(d) => d.put(buf), |
| 963 | Self::Recr(r) => r.put(buf), |
| 964 | Self::Axio(a) => a.put(buf), |
| 965 | Self::Quot(q) => q.put(buf), |
| 966 | Self::CPrj(c) => c.put(buf), |
| 967 | Self::RPrj(r) => r.put(buf), |
| 968 | Self::IPrj(i) => i.put(buf), |
| 969 | Self::DPrj(d) => d.put(buf), |
| 970 | Self::Muts(_) => unreachable!("Muts handled in Constant::put"), |
| 971 | } |
| 972 | } |
| 973 | |
| 974 | /// Deserialize a non-Muts ConstantInfo (Muts is handled separately with FLAG_MUTS) |
| 975 | pub fn get(variant: u64, buf: &mut &[u8]) -> Result<Self, String> { |
| 976 | match variant { |
| 977 | Self::CONST_DEFN => Ok(Self::Defn(Definition::get(buf)?)), |
| 978 | Self::CONST_RECR => Ok(Self::Recr(Recursor::get(buf)?)), |
| 979 | Self::CONST_AXIO => Ok(Self::Axio(Axiom::get(buf)?)), |
| 980 | Self::CONST_QUOT => Ok(Self::Quot(Quotient::get(buf)?)), |
| 981 | Self::CONST_CPRJ => Ok(Self::CPrj(ConstructorProj::get(buf)?)), |
| 982 | Self::CONST_RPRJ => Ok(Self::RPrj(RecursorProj::get(buf)?)), |