pub fn handle_server_request(single_byte_buffer: &mut [u8; 1], stream: &mut TcpStream) -> Result<(), StreamError> {
    stream.read(single_byte_buffer)?;
    match single_byte_buffer[0] {
        
        // value 1: print the message from the server
        1 => print_str_from_server(stream)?,
        
        // value 2: clear the terminal and print the message from the server
        2 => clear_and_print_str_from_server(stream)?,
        
        // value 3: print the message and return a reply in bytes
        3 => print_and_reply(stream)?,
        
        // value 4: send a message
        4 => send_message(stream)?,
        
        // value 5: exit
        5 => {
            print!("\x1b[0m\x1b[?25h"); // reset the style and show the cursor
            print!("\x1b[2J\x1b[1;1H"); // clear the screen
            print!("\x1b[K"); // redraw the screen
            std::process::exit(0)
        },

        _ => ()
    };
    Ok(())
}
/// get a request from te server and act accordingly
///
/// The request is initially encoded in a single byte sent by the server to `stream`. 
/// Five values are currently supported: 
///
/// * 1: print the next message sent by the server
/// * 2: clear the terminal and print the next message sent by the server
/// * 3: print the next message sent by the server and send back a message from stdin
/// * 4: send a message from stdin
/// * 5: close the client
get a request from te server and act accordingly
The request is initially encoded in a single byte sent by the server to `stream`.
Five values are currently supported.

print the next message sent by the server
2: clear the terminal and print the next message sent by the server
3: print the next message sent by the server and send back a message from stdin
4: send a message from stdin
5: close the client
get a request from te server and act accordingly The request is initially encoded in a single byte sent by the server to ` stream ` . Five values are currently supported . print the next message sent by the server 2 : clear the terminal and print the next message sent by the server 3 : print the next message sent by the server and send back a message from stdin 4 : send a message from stdin 5 : close the client
pub fn handle_server_request(single_byte_buffer: &mut [u8; 1], stream: &mut TcpStream) -> Result<(), StreamError> {
    stream.read(single_byte_buffer)?;
    match single_byte_buffer[0] {
        // value 1: print the message from the server
        1 => print_str_from_server(stream)?,
        // value 2: clear the terminal and print the message from the server
        2 => clear_and_print_str_from_server(stream)?,
        // value 3: print the message and return a reply in bytes
        3 => print_and_reply(stream)?,
        // value 4: send a message
        4 => send_message(stream)?,
        // value 5: exit
        5 => {
            print!("\x1b[0m\x1b[?25h"); // reset the style and show the cursor
            print!("\x1b[2J\x1b[1;1H"); // clear the screen
            print!("\x1b[K"); // redraw the screen
            std::process::exit(0)
        },
        _ => ()
    };
    Ok(())
}
pub fn handle_server_request ( single_byte_buffer : & mut [ u8 ; 1 ] , stream : & mut TcpStream ) -> Result < ( ) , StreamError > { stream . read ( single_byte_buffer ) ? ; match single_byte_buffer [ 0 ] { // value 1: print the message from the server 1 => print_str_from_server ( stream ) ? , // value 2: clear the terminal and print the message from the server 2 => clear_and_print_str_from_server ( stream ) ? , // value 3: print the message and return a reply in bytes 3 => print_and_reply ( stream ) ? , // value 4: send a message 4 => send_message ( stream ) ? , // value 5: exit 5 => { print ! ( " \x1b \x1b " ) ; // reset the style and show the cursor print ! ( " \x1b \x1b " ) ; // clear the screen print ! ( " \x1b " ) ; // redraw the screen std :: process :: exit ( 0 ) } , _ => ( ) } ; Ok ( ( ) ) }
get a request from te server and act accordingly
The request is initially encoded in a single byte sent by the server to `stream`.
get a request from te server and act accordingly The request is initially encoded in a single byte sent by the server to ` stream ` .
single_byte_buffer
&mut [u8; 1]
stream
&mut TcpStream
single_byte_buffer
&mut [u8; 1]
stream
&mut TcpStream