pub fn load_from_storage() -> Result<Option<Self>, JsValue> {
        let local_storage = try_local_storage()?;

        let save_item = local_storage.get_item("save")?;

        if let Some(save_item) = save_item {
            let world_state =
                serde_json::from_str(&save_item).map_err(|e| JsValue::from(e.to_string()))?;

            gloo_console::log!("Game successfully loaded from local storage");
            Ok(Some(world_state))
        } else {
            Ok(None)
        }
    }
/// Load the whole state of the game from local storage.
Load the whole state of the game from local storage.
Load the whole state of the game from local storage .
pub fn load_from_storage() -> Result<Option<Self>, JsValue> {
        let local_storage = try_local_storage()?;
        let save_item = local_storage.get_item("save")?;
        if let Some(save_item) = save_item {
            let world_state =
                serde_json::from_str(&save_item).map_err(|e| JsValue::from(e.to_string()))?;
            gloo_console::log!("Game successfully loaded from local storage");
            Ok(Some(world_state))
        } else {
            Ok(None)
        }
    }
pub fn load_from_storage ( ) -> Result < Option < Self > , JsValue > { let local_storage = try_local_storage ( ) ? ; let save_item = local_storage . get_item ( " " ) ? ; if let Some ( save_item ) = save_item { let world_state = serde_json :: from_str ( & save_item ) . map_err ( | e | JsValue :: from ( e . to_string ( ) ) ) ? ; gloo_console :: log ! ( " " ) ; Ok ( Some ( world_state ) ) } else { Ok ( None ) } }
Load the whole state of the game from local storage.
Load the whole state of the game from local storage .