snarkvm_circuit_program/data/record/entry/
to_bits.rsuse super::*;
impl<A: Aleo> ToBits for Entry<A, Plaintext<A>> {
type Boolean = Boolean<A>;
fn write_bits_le(&self, vec: &mut Vec<Boolean<A>>) {
match self {
Self::Constant(..) => vec.extend_from_slice(&[Boolean::constant(false), Boolean::constant(false)]),
Self::Public(..) => vec.extend_from_slice(&[Boolean::constant(false), Boolean::constant(true)]),
Self::Private(..) => vec.extend_from_slice(&[Boolean::constant(true), Boolean::constant(false)]),
};
match self {
Self::Constant(plaintext) => plaintext.write_bits_le(vec),
Self::Public(plaintext) => plaintext.write_bits_le(vec),
Self::Private(plaintext) => plaintext.write_bits_le(vec),
};
}
fn write_bits_be(&self, vec: &mut Vec<Boolean<A>>) {
match self {
Self::Constant(..) => vec.extend_from_slice(&[Boolean::constant(false), Boolean::constant(false)]),
Self::Public(..) => vec.extend_from_slice(&[Boolean::constant(false), Boolean::constant(true)]),
Self::Private(..) => vec.extend_from_slice(&[Boolean::constant(true), Boolean::constant(false)]),
};
match self {
Self::Constant(plaintext) => plaintext.write_bits_be(vec),
Self::Public(plaintext) => plaintext.write_bits_be(vec),
Self::Private(plaintext) => plaintext.write_bits_be(vec),
};
}
}
impl<A: Aleo> ToBits for Entry<A, Ciphertext<A>> {
type Boolean = Boolean<A>;
fn write_bits_le(&self, vec: &mut Vec<Boolean<A>>) {
match self {
Self::Constant(..) => vec.extend_from_slice(&[Boolean::constant(false), Boolean::constant(false)]),
Self::Public(..) => vec.extend_from_slice(&[Boolean::constant(false), Boolean::constant(true)]),
Self::Private(..) => vec.extend_from_slice(&[Boolean::constant(true), Boolean::constant(false)]),
};
match self {
Self::Constant(plaintext) => plaintext.write_bits_le(vec),
Self::Public(plaintext) => plaintext.write_bits_le(vec),
Self::Private(plaintext) => plaintext.write_bits_le(vec),
};
}
fn write_bits_be(&self, vec: &mut Vec<Boolean<A>>) {
match self {
Self::Constant(..) => vec.extend_from_slice(&[Boolean::constant(false), Boolean::constant(false)]),
Self::Public(..) => vec.extend_from_slice(&[Boolean::constant(false), Boolean::constant(true)]),
Self::Private(..) => vec.extend_from_slice(&[Boolean::constant(true), Boolean::constant(false)]),
};
match self {
Self::Constant(plaintext) => plaintext.write_bits_be(vec),
Self::Public(plaintext) => plaintext.write_bits_be(vec),
Self::Private(plaintext) => plaintext.write_bits_be(vec),
};
}
}