.and_then(|limit| (limit <= MAX_LIMIT).then_some(limit)), rune: Rune(rune), symbol: fields .remove(&TAG_SYMBOL) .and_then(|symbol| u32::try_from(symbol).ok()) .and_then(char::from_u32), term: fields .remove(&TAG_TERM) .and_then(|term| u32::try_from(term).ok()), }); Ok(Some(Self { edicts: body, etching, burn: fields.keys().any(|tag| tag % 2 == 0), })) } #[cfg(test)] pub(crate) fn encipher(&self) -> ScriptBuf { let mut payload = Vec::new(); if let Some(etching) = self.etching { varint::encode_to_vec(TAG_RUNE, &mut payload); varint::encode_to_vec(etching.rune.0, &mut payload); if etching.divisibility != 0 && etching.divisibility <= MAX_DIVISIBILITY { varint::encode_to_vec(TAG_DIVISIBILITY, &mut payload); varint::encode_to_vec(etching.divisibility.into(), &mut payload); } if let Some(symbol) = etching.symbol { varint::encode_to_vec(TAG_SYMBOL, &mut payload);