use super::Client;
use crate::common::ipc::{AlignmentContext, RpcKind};
use std::rc::Rc;
pub struct Call {
pub id: i32,
pub retry: i32,
pub rpc_request: Rc<Vec<u8>>,
_rpc_response: Option<String>,
_error: Option<String>,
pub rpc_kind: RpcKind,
_done: bool,
_external_handler: Option<String>,
pub alignment_context: Option<Rc<dyn AlignmentContext>>,
}
impl Call {
pub(super) fn new(rpc_kind: &RpcKind, param: Rc<Vec<u8>>) -> anyhow::Result<Self> {
Ok(Self {
id: Client::take_call_id()?,
retry: Client::get_retry_count()?,
rpc_request: param,
_rpc_response: None,
_error: None,
rpc_kind: rpc_kind.to_owned(),
_done: false,
_external_handler: Client::get_external_handler()?,
alignment_context: None,
})
}
pub fn set_alignment_context(&mut self, ac: Option<Rc<dyn AlignmentContext>>) {
self.alignment_context = ac;
}
}