@@ -207,7 +207,7 @@ impl Stream for WebSocket {
207
207
208
208
fn poll_next ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Option < Self :: Item > > {
209
209
match ready ! ( Pin :: new( & mut self . inner) . poll_next( cx) ) {
210
- Some ( Ok ( item) ) => Poll :: Ready ( Some ( Ok ( Message :: from_tungstenite ( item) ) ) ) ,
210
+ Some ( Ok ( item) ) => Poll :: Ready ( Some ( Ok ( Message :: from ( item) ) ) ) ,
211
211
Some ( Err ( e) ) => {
212
212
tracing:: debug!( "websocket poll error: {}" , e) ;
213
213
Poll :: Ready ( Some ( Err ( crate :: Error :: new ( e) ) ) )
@@ -231,7 +231,7 @@ impl Sink<Message> for WebSocket {
231
231
}
232
232
233
233
fn start_send ( mut self : Pin < & mut Self > , item : Message ) -> Result < ( ) , Self :: Error > {
234
- match Pin :: new ( & mut self . inner ) . start_send ( item. into_tungstenite ( ) ) {
234
+ match Pin :: new ( & mut self . inner ) . start_send ( item. into ( ) ) {
235
235
Ok ( ( ) ) => Ok ( ( ) ) ,
236
236
Err ( e) => {
237
237
tracing:: debug!( "websocket start_send error: {}" , e) ;
@@ -379,8 +379,10 @@ impl Message {
379
379
Message :: Close ( None ) => Vec :: new ( ) ,
380
380
}
381
381
}
382
+ }
382
383
383
- fn from_tungstenite ( message : protocol:: Message ) -> Self {
384
+ impl From < protocol:: Message > for Message {
385
+ fn from ( message : protocol:: Message ) -> Self {
384
386
use protocol:: Message :: * ;
385
387
386
388
match message {
@@ -392,11 +394,13 @@ impl Message {
392
394
Close ( None ) => Message :: Close ( None ) ,
393
395
}
394
396
}
397
+ }
395
398
396
- fn into_tungstenite ( self ) -> protocol:: Message {
399
+ impl From < Message > for protocol:: Message {
400
+ fn from ( message : Message ) -> Self {
397
401
use protocol:: Message :: * ;
398
402
399
- match self {
403
+ match message {
400
404
Message :: Text ( string) => Text ( string) ,
401
405
Message :: Binary ( bytes) => Binary ( bytes) ,
402
406
Message :: Ping ( bytes) => Ping ( bytes) ,
0 commit comments