fn parse_command(input: &str) -> Option<FromClient> {
    let (command, rest) = get_next_token(input)?;
    if command == "post" {
        let (group, rest) = get_next_token(rest)?;
        let message = rest.trim_start().to_string();
        return Some(FromClient::Post {
            group_name: Arc::new(group.to_string()),
            message: Arc::new(message),
        });
    } else if command == "join" {
        let (group, rest) = get_next_token(rest)?;
        if !rest.trim_start().is_empty() {
            return None;
        }
        return Some(FromClient::Join {
            group_name: Arc::new(group.to_string()),
        });
    } else {
        eprintln!("Unrecognized command: {:?}", input);
        return None;
    }
}
/// Funcion para parsear la entrada del usuario
Funcion para parsear la entrada del usuario
Funcion para parsear la entrada del usuario
fn parse_command(input: &str) -> Option<FromClient> {
    let (command, rest) = get_next_token(input)?;
    if command == "post" {
        let (group, rest) = get_next_token(rest)?;
        let message = rest.trim_start().to_string();
        return Some(FromClient::Post {
            group_name: Arc::new(group.to_string()),
            message: Arc::new(message),
        });
    } else if command == "join" {
        let (group, rest) = get_next_token(rest)?;
        if !rest.trim_start().is_empty() {
            return None;
        }
        return Some(FromClient::Join {
            group_name: Arc::new(group.to_string()),
        });
    } else {
        eprintln!("Unrecognized command: {:?}", input);
        return None;
    }
}
fn parse_command ( input : & str ) -> Option < FromClient > { let ( command , rest ) = get_next_token ( input ) ? ; if command == " " { let ( group , rest ) = get_next_token ( rest ) ? ; let message = rest . trim_start ( ) . to_string ( ) ; return Some ( FromClient :: Post { group_name : Arc :: new ( group . to_string ( ) ) , message : Arc :: new ( message ) , } ) ; } else if command == " " { let ( group , rest ) = get_next_token ( rest ) ? ; if ! rest . trim_start ( ) . is_empty ( ) { return None ; } return Some ( FromClient :: Join { group_name : Arc :: new ( group . to_string ( ) ) , } ) ; } else { eprintln ! ( " " input ) ; return None ; } }
Funcion para parsear la entrada del usuario
Funcion para parsear la entrada del usuario
input
&str
input
&str