use crate::execution_step::RcSecurityTetraplet;
use crate::JValue;
use air_interpreter_data::TracePos;
use polyplets::SecurityTetraplet;
use serde::Deserialize;
use serde::Serialize;
use std::rc::Rc;
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct LiteralAggregate {
pub result: JValue,
pub init_peer_id: Rc<str>,
pub trace_pos: TracePos,
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct ServiceResultAggregate {
pub result: JValue,
pub tetraplet: RcSecurityTetraplet,
pub trace_pos: TracePos,
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct CanonResultAggregate {
pub result: JValue,
pub peer_id: Rc<str>,
pub lambda: Rc<str>,
pub trace_pos: TracePos,
}
impl LiteralAggregate {
pub(crate) fn new(result: JValue, init_peer_id: Rc<str>, trace_pos: TracePos) -> Self {
Self {
result,
init_peer_id,
trace_pos,
}
}
pub(crate) fn get_tetraplet(&self) -> RcSecurityTetraplet {
SecurityTetraplet::literal_tetraplet(self.init_peer_id.as_ref()).into()
}
}
impl ServiceResultAggregate {
pub(crate) fn new(result: JValue, tetraplet: RcSecurityTetraplet, trace_pos: TracePos) -> Self {
Self {
result,
tetraplet,
trace_pos,
}
}
}
impl CanonResultAggregate {
pub(crate) fn new(result: JValue, peer_id: Rc<str>, lambda: &str, trace_pos: TracePos) -> Self {
Self {
result,
peer_id,
lambda: lambda.into(),
trace_pos,
}
}
pub(crate) fn get_tetraplet(&self) -> RcSecurityTetraplet {
SecurityTetraplet::new(self.peer_id.as_ref(), "", "", self.lambda.as_ref()).into()
}
}