t3rn_sdk_primitives/
signal.rs1use crate::Debug;
2use codec::{Decode, Encode, MaxEncodedLen};
3use scale_info::TypeInfo;
4
5pub trait Signaller<Hash>
11where
12 Hash: Encode + Decode + Debug + Clone + PartialEq + Eq,
13{
14 type Result;
15 fn signal(signal: &ExecutionSignal<Hash>) -> Self::Result;
16}
17
18#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug, MaxEncodedLen, TypeInfo)]
20pub struct ExecutionSignal<Hash>
21where
22 Hash: Encode + Decode + Debug + Clone + PartialEq + Eq,
23{
24 pub step: u32,
26 pub kind: SignalKind,
28 pub execution_id: Hash,
30}
31
32impl<Hash> ExecutionSignal<Hash>
33where
34 Hash: Encode + Decode + Debug + Clone + PartialEq + Eq,
35{
36 pub fn new(execution_id: &Hash, step: Option<u32>, kind: SignalKind) -> Self {
37 ExecutionSignal {
38 execution_id: execution_id.clone(),
39 step: step.unwrap_or(0),
40 kind,
41 }
42 }
43}
44
45#[derive(Debug, PartialEq, Eq, Clone, Copy, Decode, Encode, MaxEncodedLen, TypeInfo)]
46pub enum SignalKind {
47 Complete,
49 Kill(KillReason),
51}
52
53#[derive(Debug, PartialEq, Eq, Clone, Copy, Decode, Encode, MaxEncodedLen, TypeInfo)]
54pub enum KillReason {
55 Unhandled,
57 Codec,
59 Timeout,
61}