pub fn to_text(&self) -> Result<&str> {
        match *self {
            Message::Text(ref string) => Ok(string),
            Message::Binary(ref data) | Message::Ping(ref data) | Message::Pong(ref data) => {
                Ok(str::from_utf8(data)?)
            }
            Message::Close(None) => Ok(""),
            Message::Close(Some(ref frame)) => Ok(&frame.reason),
        }
    }
/// Attempt to get a &str from the WebSocket message,
/// this will try to convert binary data to utf8.
Attempt to get a &str from the WebSocket message,
this will try to convert binary data to utf8.
Attempt to get a &str from the WebSocket message this will try to convert binary data to utf8 .
pub fn to_text(&self) -> Result<&str> {
        match *self {
            Message::Text(ref string) => Ok(string),
            Message::Binary(ref data) | Message::Ping(ref data) | Message::Pong(ref data) => {
                Ok(str::from_utf8(data)?)
            }
            Message::Close(None) => Ok(""),
            Message::Close(Some(ref frame)) => Ok(&frame.reason),
        }
    }
pub fn to_text ( & self ) -> Result < & str > { match * self { Message :: Text ( ref string ) => Ok ( string ) , Message :: Binary ( ref data ) | Message :: Ping ( ref data ) | Message :: Pong ( ref data ) => { Ok ( str :: from_utf8 ( data ) ? ) } Message :: Close ( None ) => Ok ( " " ) , Message :: Close ( Some ( ref frame ) ) => Ok ( & frame . reason ) , } }
Attempt to get a &str from the WebSocket message,
this will try to convert binary data to utf8.
Attempt to get a &str from the WebSocket message this will try to convert binary data to utf8 .
&self
&self