fedimint_unknown_common/
lib.rs

1#![deny(clippy::pedantic)]
2#![allow(clippy::module_name_repetitions)]
3
4use std::fmt;
5
6use config::UnknownClientConfig;
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
14// Common contains types shared by both the client and server
15
16// The client and server configuration
17pub mod config;
18
19/// Unique name for this module
20pub const KIND: ModuleKind = ModuleKind::from_static_str("unknown");
21
22/// Modules are non-compatible with older versions
23pub const MODULE_CONSENSUS_VERSION: ModuleConsensusVersion = ModuleConsensusVersion::new(0, 0);
24
25/// Non-transaction items that will be submitted to consensus
26#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize, Encodable, Decodable)]
27pub struct UnknownConsensusItem;
28
29/// Input for a fedimint transaction
30#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, Encodable, Decodable)]
31pub struct UnknownInput;
32
33/// Output for a fedimint transaction
34#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, Encodable, Decodable)]
35pub struct UnknownOutput;
36
37/// Information needed by a client to update output funds
38#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, Encodable, Decodable)]
39pub enum UnknownOutputOutcome {}
40
41/// Errors that might be returned by the server
42#[derive(Debug, Clone, Eq, PartialEq, Hash, Error, Encodable, Decodable)]
43pub enum UnknownInputError {}
44
45/// Errors that might be returned by the server
46#[derive(Debug, Clone, Eq, PartialEq, Hash, Error, Encodable, Decodable)]
47pub enum UnknownOutputError {}
48
49/// Contains the types defined above
50pub struct UnknownModuleTypes;
51
52// Wire together the types for this module
53plugin_types_trait_impl_common!(
54    KIND,
55    UnknownModuleTypes,
56    UnknownClientConfig,
57    UnknownInput,
58    UnknownOutput,
59    UnknownOutputOutcome,
60    UnknownConsensusItem,
61    UnknownInputError,
62    UnknownOutputError
63);
64
65#[derive(Debug)]
66pub struct UnknownCommonInit;
67
68impl CommonModuleInit for UnknownCommonInit {
69    const CONSENSUS_VERSION: ModuleConsensusVersion = MODULE_CONSENSUS_VERSION;
70    const KIND: ModuleKind = KIND;
71
72    type ClientConfig = UnknownClientConfig;
73
74    fn decoder() -> Decoder {
75        UnknownModuleTypes::decoder_builder().build()
76    }
77}
78
79impl fmt::Display for UnknownClientConfig {
80    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
81        write!(f, "UnknownClientConfig")
82    }
83}
84impl fmt::Display for UnknownInput {
85    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
86        write!(f, "UnknownInput")
87    }
88}
89
90impl fmt::Display for UnknownOutput {
91    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
92        write!(f, "UnknownOutput")
93    }
94}
95
96impl fmt::Display for UnknownOutputOutcome {
97    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
98        write!(f, "UnknownOutputOutcome")
99    }
100}
101
102impl fmt::Display for UnknownConsensusItem {
103    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
104        write!(f, "UnknownConsensusItem")
105    }
106}