@@ -38,7 +38,7 @@ pub trait Partial {
3838 /// All partial messages belonging to the same logical message should return
3939 /// the same group ID. This is used to associate partial messages together
4040 /// during reconstruction.
41- fn group_id ( & self ) -> & [ u8 ] ;
41+ fn group_id ( & self ) -> impl AsRef < [ u8 ] > ;
4242
4343 /// Returns metadata describing which parts of the message are missing.
4444 ///
@@ -48,7 +48,7 @@ pub trait Partial {
4848 ///
4949 /// The returned bytes will be sent in PartialIWANT messages to request
5050 /// missing parts from peers.
51- fn missing_parts ( & self ) -> Option < & [ u8 ] > ;
51+ fn missing_parts ( & self ) -> Option < impl AsRef < [ u8 ] > > ;
5252
5353 /// Returns metadata describing which parts of the message are available.
5454 ///
@@ -58,7 +58,7 @@ pub trait Partial {
5858 ///
5959 /// The returned bytes will be sent in PartialIHAVE messages to advertise
6060 /// available parts to peers.
61- fn available_parts ( & self ) -> Option < & [ u8 ] > ;
61+ fn available_parts ( & self ) -> Option < impl AsRef < [ u8 ] > > ;
6262
6363 /// Generates partial message bytes from the given metadata.
6464 ///
@@ -72,7 +72,7 @@ pub trait Partial {
7272 fn partial_message_bytes_from_metadata (
7373 & self ,
7474 metadata : & [ u8 ] ,
75- ) -> Result < ( Vec < u8 > , Option < Vec < u8 > > ) , PartialMessageError > ;
75+ ) -> Result < ( impl AsRef < [ u8 ] > , Option < impl AsRef < [ u8 ] > > ) , PartialMessageError > ;
7676
7777 /// Extends this message with received partial message data.
7878 ///
@@ -87,34 +87,3 @@ pub trait Partial {
8787 data : & [ u8 ] ,
8888 ) -> Result < ( ) , PartialMessageError > ;
8989}
90-
91- /// Default implementation that disables partial messages.
92- impl Partial for ( ) {
93- fn group_id ( & self ) -> & [ u8 ] {
94- & [ ]
95- }
96-
97- fn missing_parts ( & self ) -> Option < & [ u8 ] > {
98- None
99- }
100-
101- fn available_parts ( & self ) -> Option < & [ u8 ] > {
102- None
103- }
104-
105- fn partial_message_bytes_from_metadata (
106- & self ,
107- _metadata : & [ u8 ] ,
108- ) -> Result < ( Vec < u8 > , Option < Vec < u8 > > ) , PartialMessageError > {
109- Ok ( ( vec ! [ ] , None ) )
110- }
111-
112- fn extend_from_encoded_partial_message (
113- & mut self ,
114- _data : & [ u8 ] ,
115- ) -> Result < ( ) , PartialMessageError > {
116- // This should never be called since we never advertise having or wanting parts,
117- // but if it is called, just ignore the data silently
118- Ok ( ( ) )
119- }
120- }
0 commit comments