Merge pull request #2625 from tnull/2023-09-moar-tests-n-fixes
[rust-lightning] / lightning / src / sign / type_resolver.rs
1 use crate::sign::{ChannelSigner, EcdsaChannelSigner};
2
3 pub(crate) enum ChannelSignerType<ECS: EcdsaChannelSigner> {
4         // in practice, this will only ever be an EcdsaChannelSigner (specifically, Writeable)
5         Ecdsa(ECS)
6 }
7
8 impl<ECS: EcdsaChannelSigner> ChannelSignerType<ECS>{
9         pub(crate) fn as_ref(&self) -> &dyn ChannelSigner {
10                 match self {
11                         ChannelSignerType::Ecdsa(ecs) => ecs
12                 }
13         }
14
15         pub(crate) fn as_mut(&mut self) -> &mut dyn ChannelSigner {
16                 match self {
17                         ChannelSignerType::Ecdsa(ecs) => ecs
18                 }
19         }
20
21         pub(crate) fn as_ecdsa(&self) -> Option<&ECS> {
22                 match self {
23                         ChannelSignerType::Ecdsa(ecs) => Some(ecs)
24                 }
25         }
26
27         #[allow(unused)]
28         pub(crate) fn as_mut_ecdsa(&mut self) -> Option<&mut ECS> {
29                 match self {
30                         ChannelSignerType::Ecdsa(ecs) => Some(ecs)
31                 }
32         }
33 }