holochain_zome_types/
call.rs1use crate::prelude::*;
2use holo_hash::AgentPubKey;
3use holochain_wasmer_common::WasmError;
4
5pub type RoleName = String;
7
8#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
9pub enum CallTargetCell {
10 OtherCell(CellId),
11 OtherRole(RoleName),
12 Local,
13}
14
15#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
16pub enum CallTarget {
17 NetworkAgent(AgentPubKey),
18 ConductorCell(CallTargetCell),
19}
20
21#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
22pub struct Call {
23 pub target: CallTarget,
24 pub zome_name: ZomeName,
25 pub fn_name: FunctionName,
26 pub cap_secret: Option<CapSecret>,
27 pub payload: ExternIO,
28}
29
30impl Call {
31 pub fn new(
32 target: CallTarget,
33 zome_name: ZomeName,
34 fn_name: FunctionName,
35 cap_secret: Option<CapSecret>,
36 payload: ExternIO,
37 ) -> Self {
38 Self {
39 target,
40 zome_name,
41 fn_name,
42 cap_secret,
43 payload,
44 }
45 }
46
47 pub fn target(&self) -> &CallTarget {
48 &self.target
49 }
50
51 pub fn zome_name(&self) -> &ZomeName {
52 &self.zome_name
53 }
54
55 pub fn fn_name(&self) -> &FunctionName {
56 &self.fn_name
57 }
58
59 pub fn cap_secret(&self) -> Option<&CapSecret> {
60 self.cap_secret.as_ref()
61 }
62
63 pub fn payload(&self) -> &ExternIO {
64 &self.payload
65 }
66}
67
68#[allow(missing_docs)]
69pub trait CallbackResult: Sized {
70 fn is_definitive(&self) -> bool;
76 fn try_from_wasm_error(wasm_error: WasmError) -> Result<Self, WasmError>;
84}