snarkvm_console_program/data/record/
to_bits.rsuse super::*;
impl<N: Network> ToBits for Record<N, Plaintext<N>> {
fn write_bits_le(&self, vec: &mut Vec<bool>) {
let mut data_bits_le = vec![];
for (identifier, entry) in &self.data {
identifier.write_bits_le(&mut data_bits_le);
entry.write_bits_le(&mut data_bits_le);
}
self.owner.write_bits_le(vec);
u32::try_from(data_bits_le.len()).or_halt_with::<N>("Record data exceeds u32::MAX bits").write_bits_le(vec);
vec.extend_from_slice(&data_bits_le);
self.nonce.write_bits_le(vec);
}
fn write_bits_be(&self, vec: &mut Vec<bool>) {
let mut data_bits_be = vec![];
for (identifier, entry) in &self.data {
identifier.write_bits_be(&mut data_bits_be);
entry.write_bits_be(&mut data_bits_be);
}
self.owner.write_bits_be(vec);
u32::try_from(data_bits_be.len()).or_halt_with::<N>("Record data exceeds u32::MAX bits").write_bits_be(vec);
vec.extend_from_slice(&data_bits_be);
self.nonce.write_bits_be(vec);
}
}
impl<N: Network> ToBits for Record<N, Ciphertext<N>> {
fn write_bits_le(&self, vec: &mut Vec<bool>) {
let mut data_bits_le = vec![];
for (identifier, entry) in &self.data {
identifier.write_bits_le(&mut data_bits_le);
entry.write_bits_le(&mut data_bits_le);
}
self.owner.write_bits_le(vec);
u32::try_from(data_bits_le.len()).or_halt_with::<N>("Record data exceeds u32::MAX bits").write_bits_le(vec);
vec.extend_from_slice(&data_bits_le);
self.nonce.write_bits_le(vec);
}
fn write_bits_be(&self, vec: &mut Vec<bool>) {
let mut data_bits_be = vec![];
for (identifier, entry) in &self.data {
identifier.write_bits_be(&mut data_bits_be);
entry.write_bits_be(&mut data_bits_be);
}
self.owner.write_bits_be(vec);
u32::try_from(data_bits_be.len()).or_halt_with::<N>("Record data exceeds u32::MAX bits").write_bits_be(vec);
vec.extend_from_slice(&data_bits_be);
self.nonce.write_bits_be(vec);
}
}