pub async fn new() -> App {
        let mut matches_info = vec![];
        let mut match_name_id: Vec<(String, String)> = vec![];
        let mut scorecard: Vec<MatchInningsInfo> = vec![];
        let req_clt = Client::new();

        // First get all currently live matches
        match get_all_live_matches_id_and_short_name(&req_clt).await {
            Ok(v) => match_name_id = v,
            Err(e) => {
                println!("{:?}", e);
            }
        };

        // For each live match populate required data
        for (name, id) in &match_name_id {
            if let Ok(match_id) = id.parse() {
                if let Ok(json) = get_match_info_from_id(&req_clt, match_id).await {
                    if prepare_scorecard(&req_clt, match_id, &mut scorecard)
                        .await
                        .is_ok()
                    {
                        matches_info.push(MatchInfo::new(
                            name.to_string(),
                            match_id,
                            format!("{}{}", String::from(CRICBUZZ_MATCH_API), match_id),
                            json,
                            scorecard.clone(),
                        ));
                        scorecard.clear();
                    } else {
                        matches_info.push(MatchInfo::new(
                            name.to_string(),
                            match_id,
                            format!("{}{}", String::from(CRICBUZZ_MATCH_API), match_id),
                            json,
                            vec![],
                        ));
                    }
                }
            }
        }

        App {
            req_clt,
            matches_info,
        }
    }
/// Returs a new App containing all live matches
Returs a new App containing all live matches
Returs a new App containing all live matches
pub async fn new() -> App {
        let mut matches_info = vec![];
        let mut match_name_id: Vec<(String, String)> = vec![];
        let mut scorecard: Vec<MatchInningsInfo> = vec![];
        let req_clt = Client::new();
        // First get all currently live matches
        match get_all_live_matches_id_and_short_name(&req_clt).await {
            Ok(v) => match_name_id = v,
            Err(e) => {
                println!("{:?}", e);
            }
        };
        // For each live match populate required data
        for (name, id) in &match_name_id {
            if let Ok(match_id) = id.parse() {
                if let Ok(json) = get_match_info_from_id(&req_clt, match_id).await {
                    if prepare_scorecard(&req_clt, match_id, &mut scorecard)
                        .await
                        .is_ok()
                    {
                        matches_info.push(MatchInfo::new(
                            name.to_string(),
                            match_id,
                            format!("{}{}", String::from(CRICBUZZ_MATCH_API), match_id),
                            json,
                            scorecard.clone(),
                        ));
                        scorecard.clear();
                    } else {
                        matches_info.push(MatchInfo::new(
                            name.to_string(),
                            match_id,
                            format!("{}{}", String::from(CRICBUZZ_MATCH_API), match_id),
                            json,
                            vec![],
                        ));
                    }
                }
            }
        }
        App {
            req_clt,
            matches_info,
        }
    }
pub async fn new ( ) -> App { let mut matches_info = vec ! [ ] ; let mut match_name_id : Vec < ( String , String ) > = vec ! [ ] ; let mut scorecard : Vec < MatchInningsInfo > = vec ! [ ] ; let req_clt = Client :: new ( ) ; // First get all currently live matches match get_all_live_matches_id_and_short_name ( & req_clt ) . await { Ok ( v ) => match_name_id = v , Err ( e ) => { println ! ( " " e ) ; } } ; // For each live match populate required data for ( name , id ) in & match_name_id { if let Ok ( match_id ) = id . parse ( ) { if let Ok ( json ) = get_match_info_from_id ( & req_clt , match_id ) . await { if prepare_scorecard ( & req_clt , match_id , & mut scorecard ) . await . is_ok ( ) { matches_info . push ( MatchInfo :: new ( name . to_string ( ) , match_id , format ! ( " " String from ( CRICBUZZ_MATCH_API ) match_id ) , json , scorecard . clone ( ) , ) ) ; scorecard . clear ( ) ; } else { matches_info . push ( MatchInfo :: new ( name . to_string ( ) , match_id , format ! ( " " String from ( CRICBUZZ_MATCH_API ) match_id ) , json , vec ! [ ] , ) ) ; } } } } App { req_clt , matches_info , } }
Returs a new App containing all live matches
Returs a new App containing all live matches