lightning 0.2.2

A Complete Bitcoin Lightning Library in Rust. Handles the core functionality of the Lightning Network, allowing clients to implement custom wallet, chain interactions, storage and network logic without enforcing a specific runtime.
Documentation
use crate::sign::{ChannelSigner, SignerProvider};
use core::ops::Deref;

pub(crate) enum ChannelSignerType<SP: Deref>
where
	SP::Target: SignerProvider,
{
	// in practice, this will only ever be an EcdsaChannelSigner (specifically, Writeable)
	Ecdsa(<SP::Target as SignerProvider>::EcdsaSigner),
	#[cfg(taproot)]
	#[allow(unused)]
	Taproot(<SP::Target as SignerProvider>::TaprootSigner),
}

impl<SP: Deref> ChannelSignerType<SP>
where
	SP::Target: SignerProvider,
{
	pub(crate) fn as_ref(&self) -> &dyn ChannelSigner {
		match self {
			ChannelSignerType::Ecdsa(ecs) => ecs,
			#[cfg(taproot)]
			#[allow(unused)]
			ChannelSignerType::Taproot(tcs) => tcs,
		}
	}

	#[allow(unused)]
	pub(crate) fn as_ecdsa(&self) -> Option<&<SP::Target as SignerProvider>::EcdsaSigner> {
		match self {
			ChannelSignerType::Ecdsa(ecs) => Some(ecs),
			_ => None,
		}
	}

	#[allow(unused)]
	pub(crate) fn as_mut_ecdsa(
		&mut self,
	) -> Option<&mut <SP::Target as SignerProvider>::EcdsaSigner> {
		match self {
			ChannelSignerType::Ecdsa(ecs) => Some(ecs),
			_ => None,
		}
	}
}