X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Ffeatures.rs;fp=lightning%2Fsrc%2Fln%2Ffeatures.rs;h=b90748aa87b7e5cd55bf0461244fd2c654feb7eb;hb=f3b63e4dab439166827c1d9f144db1abc824d6ec;hp=eb0100db675de8842e1d317d4a2b9c5c6e7b9ab1;hpb=1bb9e64ebc6afaa21afcef4f71bb83054d9b2023;p=rust-lightning diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index eb0100db..b90748aa 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -89,6 +89,28 @@ mod sealed { )* ]; } + + impl alloc::fmt::Display for Features<$context> { + fn fmt(&self, fmt: &mut alloc::fmt::Formatter) -> Result<(), alloc::fmt::Error> { + $( + $( + fmt.write_fmt(format_args!("{}: {}, ", stringify!($required_feature), + if <$context as $required_feature>::requires_feature(&self.flags) { "required" } + else if <$context as $required_feature>::supports_feature(&self.flags) { "supported" } + else { "not supported" }))?; + )* + $( + fmt.write_fmt(format_args!("{}: {}, ", stringify!($optional_feature), + if <$context as $optional_feature>::requires_feature(&self.flags) { "required" } + else if <$context as $optional_feature>::supports_feature(&self.flags) { "supported" } + else { "not supported" }))?; + )* + )* + fmt.write_fmt(format_args!("unknown flags: {}", + if self.requires_unknown_bits() { "required" } + else if self.supports_unknown_bits() { "supported" } else { "none" })) + } + } }; } @@ -566,6 +588,7 @@ impl Features { pub(crate) fn requires_data_loss_protect(&self) -> bool { ::requires_feature(&self.flags) } + #[cfg(test)] pub(crate) fn supports_data_loss_protect(&self) -> bool { ::supports_feature(&self.flags) }