fedimint_empty_common/
lib.rs1#![deny(clippy::pedantic)]
2#![allow(clippy::module_name_repetitions)]
3
4use std::fmt;
5
6use config::EmptyClientConfig;
7use fedimint_core::core::{Decoder, ModuleInstanceId, ModuleKind};
8use fedimint_core::encoding::{Decodable, Encodable};
9use fedimint_core::module::{CommonModuleInit, ModuleCommon, ModuleConsensusVersion};
10use fedimint_core::plugin_types_trait_impl_common;
11use serde::{Deserialize, Serialize};
12use thiserror::Error;
13
14pub mod config;
18
19pub const KIND: ModuleKind = ModuleKind::from_static_str("dummy");
21
22pub const MODULE_CONSENSUS_VERSION: ModuleConsensusVersion = ModuleConsensusVersion::new(0, 0);
24
25#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize, Encodable, Decodable)]
27pub struct EmptyConsensusItem;
28
29#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, Encodable, Decodable)]
31pub struct EmptyInput;
32
33#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, Encodable, Decodable)]
35pub struct EmptyOutput;
36
37#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, Encodable, Decodable)]
39pub struct EmptyOutputOutcome;
40
41#[derive(Debug, Clone, Eq, PartialEq, Hash, Error, Encodable, Decodable)]
43pub enum EmptyInputError {
44 #[error("This module does not support inputs")]
45 NotSupported,
46}
47
48#[derive(Debug, Clone, Eq, PartialEq, Hash, Error, Encodable, Decodable)]
50pub enum EmptyOutputError {
51 #[error("This module does not support outputs")]
52 NotSupported,
53}
54
55pub struct EmptyModuleTypes;
57
58plugin_types_trait_impl_common!(
60 KIND,
61 EmptyModuleTypes,
62 EmptyClientConfig,
63 EmptyInput,
64 EmptyOutput,
65 EmptyOutputOutcome,
66 EmptyConsensusItem,
67 EmptyInputError,
68 EmptyOutputError
69);
70
71#[derive(Debug)]
72pub struct EmptyCommonInit;
73
74impl CommonModuleInit for EmptyCommonInit {
75 const CONSENSUS_VERSION: ModuleConsensusVersion = MODULE_CONSENSUS_VERSION;
76 const KIND: ModuleKind = KIND;
77
78 type ClientConfig = EmptyClientConfig;
79
80 fn decoder() -> Decoder {
81 EmptyModuleTypes::decoder_builder().build()
82 }
83}
84
85impl fmt::Display for EmptyClientConfig {
86 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
87 write!(f, "EmptyClientConfig")
88 }
89}
90impl fmt::Display for EmptyInput {
91 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
92 write!(f, "EmptyInput")
93 }
94}
95
96impl fmt::Display for EmptyOutput {
97 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
98 write!(f, "EmptyOutput")
99 }
100}
101
102impl fmt::Display for EmptyOutputOutcome {
103 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
104 write!(f, "EmptyOutputOutcome")
105 }
106}
107
108impl fmt::Display for EmptyConsensusItem {
109 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
110 write!(f, "EmptyConsensusItem")
111 }
112}