@@ -32,11 +32,11 @@ use routing::network_graph::NetGraphMsgHandler;
32
32
use prelude:: * ;
33
33
use io;
34
34
use alloc:: collections:: LinkedList ;
35
- use alloc:: fmt:: Debug ;
36
35
use sync:: { Arc , Mutex } ;
37
36
use core:: sync:: atomic:: { AtomicUsize , Ordering } ;
38
37
use core:: { cmp, hash, fmt, mem} ;
39
38
use core:: ops:: Deref ;
39
+ use core:: convert:: Infallible ;
40
40
#[ cfg( feature = "std" ) ] use std:: error;
41
41
42
42
use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
@@ -80,28 +80,28 @@ impl Deref for IgnoringMessageHandler {
80
80
fn deref ( & self ) -> & Self { self }
81
81
}
82
82
83
- impl wire:: Type for ( ) {
83
+ // Implement Type for Infallible, note that it cannot be constructed, and thus you can never call a
84
+ // method that takes self for it.
85
+ impl wire:: Type for Infallible {
84
86
fn type_id ( & self ) -> u16 {
85
- // We should never call this for `DummyCustomType`
86
87
unreachable ! ( ) ;
87
88
}
88
89
}
89
-
90
- impl Writeable for ( ) {
90
+ impl Writeable for Infallible {
91
91
fn write < W : Writer > ( & self , _: & mut W ) -> Result < ( ) , io:: Error > {
92
92
unreachable ! ( ) ;
93
93
}
94
94
}
95
95
96
96
impl wire:: CustomMessageReader for IgnoringMessageHandler {
97
- type CustomMessage = ( ) ;
97
+ type CustomMessage = Infallible ;
98
98
fn read < R : io:: Read > ( & self , _message_type : u16 , _buffer : & mut R ) -> Result < Option < Self :: CustomMessage > , msgs:: DecodeError > {
99
99
Ok ( None )
100
100
}
101
101
}
102
102
103
103
impl CustomMessageHandler for IgnoringMessageHandler {
104
- fn handle_custom_message ( & self , _msg : Self :: CustomMessage , _sender_node_id : & PublicKey ) -> Result < ( ) , LightningError > {
104
+ fn handle_custom_message ( & self , _msg : Infallible , _sender_node_id : & PublicKey ) -> Result < ( ) , LightningError > {
105
105
// Since we always return `None` in the read the handle method should never be called.
106
106
unreachable ! ( ) ;
107
107
}
@@ -469,7 +469,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
469
469
CM :: Target : ChannelMessageHandler ,
470
470
RM :: Target : RoutingMessageHandler ,
471
471
L :: Target : Logger ,
472
- CMH :: Target : CustomMessageHandler + wire :: CustomMessageReader {
472
+ CMH :: Target : CustomMessageHandler {
473
473
/// Constructs a new PeerManager with the given message handlers and node_id secret key
474
474
/// ephemeral_random_data is used to derive per-connection ephemeral keys and must be
475
475
/// cryptographically secure random bytes.
@@ -719,7 +719,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
719
719
}
720
720
721
721
/// Append a message to a peer's pending outbound/write buffer, and update the map of peers needing sends accordingly.
722
- fn enqueue_message < M : wire:: Type + Writeable + Debug > ( & self , peer : & mut Peer , message : & M ) {
722
+ fn enqueue_message < M : wire:: Type > ( & self , peer : & mut Peer , message : & M ) {
723
723
let mut buffer = VecWriter ( Vec :: with_capacity ( 2048 ) ) ;
724
724
wire:: write ( message, & mut buffer) . unwrap ( ) ; // crash if the write failed
725
725
let encoded_message = buffer. 0 ;
0 commit comments