use crate::{
fhe::{with_fhe_ctx, FheContextOps},
types::{intern::FheProgramNode, NumCiphertexts},
};
pub trait Output {
type Output;
fn output(&self) -> Self::Output;
}
impl<T> Output for FheProgramNode<T>
where
T: NumCiphertexts,
{
type Output = FheProgramNode<T>;
fn output(&self) -> Self::Output {
let mut ids = Vec::with_capacity(self.ids.len());
for i in 0..self.ids.len() {
ids.push(with_fhe_ctx(|ctx| ctx.add_output(self.ids[i])));
}
FheProgramNode::new(&ids)
}
}
impl<T, const N: usize> Output for [T; N]
where
T: Output + NumCiphertexts + Copy,
{
type Output = [T::Output; N];
fn output(&self) -> Self::Output {
self.map(|i| i.output())
}
}