websocketing 0.1.0

WebSocketing is a WebSockets actor framework.
Documentation
use async_tungstenite::{WebSocketReceiver, WebSocketStream};

use async_tungstenite::tokio::TokioAdapter;

use highly_sendable::text::SendableText;

use async_tungstenite::tungstenite::http::Response;

use async_tungstenite::tungstenite::{Error, Message};

use tokio::net::TcpStream;

#[derive(Debug)]
pub enum WebSocketActorInputMessage
{

    WebSocket(WebSocketStream<TokioAdapter<TcpStream>>),
    //NewTcpConnection(SendableText),
    //TcpStream(TcpStream),
    Close,
    CloseNow,
    //Disconnect,
    //DisconnectNow,
    //WriteFrame(OwnedFrame),
    SendMessage(Message)

}

impl WebSocketActorInputMessage
{

    pub fn is_web_socket(&self) -> bool
    {

        matches!(self, WebSocketActorInputMessage::WebSocket(_))

    }

    pub fn is_close(&self) -> bool
    {

        matches!(self, WebSocketActorInputMessage::Close)

    }

    pub fn is_close_now(&self) -> bool
    {

        matches!(self, WebSocketActorInputMessage::CloseNow)

    }

    /*
    pub fn is_new_tcp_connection(&self) -> bool
    {

        matches!(self, WebSocketActorInputMessage::NewTcpConnection(_))

    }

    pub fn is_disconnect(&self) -> bool
    {

        matches!(self, WebSocketActorInputMessage::Disconnect)

    }

    pub fn is_disconnect_now(&self) -> bool
    {

        matches!(self, WebSocketActorInputMessage::DisconnectNow)

    }
    */

    pub fn is_send_message(&self) -> bool
    {

        matches!(self, WebSocketActorInputMessage::SendMessage(_))

    }

    /*
    pub fn is_write_frame(&self) -> bool
    {

        matches!(self, WebSocketActorInputMessage::WriteFrame(_))

    }
    */

}

#[derive(Debug)]
pub enum WebSocketActorOutputMessage
{

    WebSocketEngaged,
    //ConnectionSucceeded(Response<Option<Vec<u8>>>), //(SendableText),
    //NewConnection,
    ConnectionError(Error), //(SendableText),                // Errors relating to active connections.Indicate that it is the reader or witer actor having the issue at some point. (Equivalent to the Disconnected variant with a message.)
    //NonConnectionError, //(NonConnectionError),       // Errors relating to issues and situations surrounding connections, not necessarily the connections themselves.       (If you're connected, don't drop it because you've received this error.)
    Closing,
    //Disconnecting, //(SendableText),
    Closed,
    //Disconnected, //(SendableText),
    //NotOpen,
    NotConnected, //(SendableText),
    //SendingPongFrame,
    //SendingCloseFrame,
    //PingFrameReceived, //(SendableText),
    //PingFrameSent,
    //PongFrameReceived, //(SendableText),
    //PongFrameSent,
    //CloseFrameReceived, //(SendableText)
    //CloseFrameSent,
    //ReadFrame(OwnedFrame),
    ClosureWindowElapsed,      //Disconnected
    Message(Message)

}

impl WebSocketActorOutputMessage
{

    pub fn is_web_socket_engaged(&self) -> bool
    {

        matches!(self, Self::WebSocketEngaged)

    }

    pub fn is_connection_error(&self) -> bool
    {

        matches!(self, Self::ConnectionError(_))

    }

    pub fn is_closing(&self) -> bool
    {

        matches!(self, Self::Closing)

    }

    pub fn is_closed(&self) -> bool
    {

        matches!(self, Self::Closed)

    }

    pub fn is_not_connected(&self) -> bool
    {

        matches!(self, Self::NotConnected)

    }

    pub fn is_closure_window_elapsed(&self) -> bool
    {

        matches!(self, Self::ClosureWindowElapsed)

    }

    pub fn is_message(&self) -> bool
    {

        matches!(self, Self::Message(_))

    }

}

/*
pub enum WebSocketWorkerActorInputMessage
{

    Disconnect,
    DisconnectNow,
    //WriteFrame(OwnedFrame),

}
*/

#[derive(Debug)]
pub enum WebSocketReaderActorInputMessage
{

    WebSocket(WebSocketReceiver<TokioAdapter<TcpStream>>),
    //NewConnection(WebSocketReceiver<TokioAdapter<TcpStream>>), //(WebSocketReader),
    //Disconnecting, //Needed?
    Close,
    CloseNow
    //Disconnect,    //Needed?
    //DisconnectNow

}

impl WebSocketReaderActorInputMessage
{

    pub fn is_web_socket(&self) -> bool
    {

        matches!(self, Self::WebSocket(_))

    }

    /*
    pub fn is_new_connection(&self) -> bool
    {

        matches!(self, Self::NewConnection(_))

    }
    */

    /*
    pub fn is_disconnecting(&self) -> bool
    {

        matches!(self, Self::Disconnecting)

    }
    */

    pub fn is_close(&self) -> bool
    {

        matches!(self, Self::Close)

    }

    /*
    pub fn is_disconnect(&self) -> bool
    {

        matches!(self, Self::Disconnect)

    }
    */

    /*
    pub fn is_disconnect_now(&self) -> bool
    {

        matches!(self, Self::DisconnectNow)

    }
    */


}

#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Debug)]
pub enum WebSocketReaderActorOutputMessage
{

    //ReadFrame(), //(OwnedFrame), //Should be used for passing obligated frames to the WebSocketActor only.
    //ReceiveMessage(Message),
    Closing,
    Closed
    //Disconnected,
    //ConnectionError(SendableText) //Send the ConnectionError directly.
    
}

impl WebSocketReaderActorOutputMessage
{

    /*
    pub fn is_receive_message(&self) -> bool
    {

        matches!(self, Self::ReceiveMessage(_))

    }
    */

    pub fn is_closed(&self) -> bool
    {

        matches!(self, Self::Closed)

    }

    /*
    pub fn is_read_frame(&self) -> bool
    {

        matches!(self, Self::ReadFrame())

    }
    */

    /*
    pub fn is_disconnected(&self) -> bool
    {

        matches!(self, Self::Disconnected)

    }
    */

}