oasis_runtime_sdk/types/
message.rs

1use std::fmt::Debug;
2
3use oasis_core_runtime::consensus;
4
5/// Result of a message being processed by the consensus layer.
6pub type MessageEvent = consensus::roothash::MessageEvent;
7
8/// Handler name and context to be called after message is executed.
9#[derive(Clone, Debug, cbor::Encode, cbor::Decode)]
10#[cbor(no_default)]
11pub struct MessageEventHookInvocation {
12    pub hook_name: String,
13    pub payload: cbor::Value,
14}
15
16impl MessageEventHookInvocation {
17    /// Constructs a new message hook invocation.
18    pub fn new<S: cbor::Encode>(name: String, payload: S) -> Self {
19        Self {
20            hook_name: name,
21            payload: cbor::to_value(payload),
22        }
23    }
24}
25
26/// Result of a message being processed by the consensus layer combined with the context for the
27/// result handler.
28#[derive(Clone, Debug)]
29pub struct MessageResult {
30    pub event: MessageEvent,
31    pub context: cbor::Value,
32}