1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Signals which can be emitted from within Holochain, out across an interface.
//! There are two main kinds of Signal: system-defined, and app-defined:
//! - App-defined signals are produced via the `emit_signal` host function.
//! - System-defined signals are produced in various places in the system
use crate::impl_from;
use holochain_serialized_bytes::prelude::*;
use holochain_zome_types::prelude::*;
/// A Signal is some information emitted from within Holochain out through
/// an Interface
#[derive(Clone, Debug, Serialize, Deserialize, SerializedBytes, PartialEq, Eq)]
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
pub enum Signal {
/// Signal from a Cell, generated by `emit_signal`
App {
/// The Cell from which the signal was emitted
cell_id: CellId,
/// The Zome from which the signal was emitted
zome_name: ZomeName,
/// The actual signal that was emitted
signal: AppSignal,
},
/// System-defined signals
System(SystemSignal),
}
impl Signal {
/// Parse from vec.
pub fn try_from_vec(v: Vec<u8>) -> Result<Self, SerializedBytesError> {
Self::try_from(SerializedBytes::from(UnsafeBytes::from(v)))
}
}
/// A Signal which originates from within the Holochain system, as opposed to
/// from within a Cell
#[derive(Clone, Debug, Serialize, Deserialize, SerializedBytes, PartialEq, Eq)]
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
pub enum SystemSignal {
/// A countersigning session has successfully completed.
SuccessfulCountersigning(EntryHash),
/// A countersigning session has been abandoned.
AbandonedCountersigning(EntryHash),
}
impl_from! {
SystemSignal => Signal, |s| { Self::System(s) },
}