@@ -38,7 +38,7 @@ pub trait Partial {
38
38
/// All partial messages belonging to the same logical message should return
39
39
/// the same group ID. This is used to associate partial messages together
40
40
/// during reconstruction.
41
- fn group_id ( & self ) -> & [ u8 ] ;
41
+ fn group_id ( & self ) -> impl AsRef < [ u8 ] > ;
42
42
43
43
/// Returns metadata describing which parts of the message are missing.
44
44
///
@@ -48,7 +48,7 @@ pub trait Partial {
48
48
///
49
49
/// The returned bytes will be sent in PartialIWANT messages to request
50
50
/// missing parts from peers.
51
- fn missing_parts ( & self ) -> Option < & [ u8 ] > ;
51
+ fn missing_parts ( & self ) -> Option < impl AsRef < [ u8 ] > > ;
52
52
53
53
/// Returns metadata describing which parts of the message are available.
54
54
///
@@ -58,7 +58,7 @@ pub trait Partial {
58
58
///
59
59
/// The returned bytes will be sent in PartialIHAVE messages to advertise
60
60
/// available parts to peers.
61
- fn available_parts ( & self ) -> Option < & [ u8 ] > ;
61
+ fn available_parts ( & self ) -> Option < impl AsRef < [ u8 ] > > ;
62
62
63
63
/// Generates partial message bytes from the given metadata.
64
64
///
@@ -72,7 +72,7 @@ pub trait Partial {
72
72
fn partial_message_bytes_from_metadata (
73
73
& self ,
74
74
metadata : & [ u8 ] ,
75
- ) -> Result < ( Vec < u8 > , Option < Vec < u8 > > ) , PartialMessageError > ;
75
+ ) -> Result < ( impl AsRef < [ u8 ] > , Option < impl AsRef < [ u8 ] > > ) , PartialMessageError > ;
76
76
77
77
/// Extends this message with received partial message data.
78
78
///
@@ -87,34 +87,3 @@ pub trait Partial {
87
87
data : & [ u8 ] ,
88
88
) -> Result < ( ) , PartialMessageError > ;
89
89
}
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