vihaco_runtime/no_message.rs
1// SPDX-FileCopyrightText: 2026 The vihaco Authors
2// SPDX-License-Identifier: MIT
3
4/// Execution input for instructions that need no runtime-supplied message.
5///
6/// Unlike `()`, this type explicitly names the absence of an execution message.
7/// Instruction operands and execution effects are independent of this choice.
8/// Construct it with [`NoMessage::new`] or [`Default`] so callers do not depend
9/// on its representation.
10///
11/// ```
12/// use vihaco_runtime::{Message, NoMessage};
13///
14/// const INPUT: NoMessage = NoMessage::new();
15/// fn accept_message<M: Message>(_: M) {}
16/// accept_message(INPUT);
17/// assert_eq!(INPUT, NoMessage::default());
18/// ```
19///
20/// Ordinary unit values are not interchangeable with this message:
21///
22/// ```compile_fail,E0308
23/// use vihaco_runtime::NoMessage;
24/// let message: NoMessage = ();
25/// ```
26#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
27pub struct NoMessage {
28 _private: (),
29}
30
31impl NoMessage {
32 /// Construct an empty execution message.
33 pub const fn new() -> Self {
34 Self { _private: () }
35 }
36}
37
38impl crate::Message for NoMessage {}