Crate rl_hours_tracker

Crate rl_hours_tracker 

Source
Expand description

§Rocket League Hours Tracker

This was made specifically for the Epic Games version of Rocket League as the Epic Games launcher has no way of showing the past two hours played in the same way that steam is able to.

However, this program can and should still work with the steam version of the game.

It is HIGHLY recommended to not manually alter the files that are created by this program otherwise it could lead to unwanted behaviour by the program

    println!("You got it Oneil :)");

§Library

The Rocket League Hours Tracker library contains modules which provide additional functionality to the Rocket League Hours Tracker binary. This library currently implements the website_files module, which provides the functionality to generate the Html, CSS, and JavaScript for the Rocket League Hours Tracker website, and the update module, which is the built in updater for the binary which retrieves the update from the GitHub repository.

The website functionality takes adavantage of the build_html library, which allows us to generate the Html for the website, alongside the webbrowser library, which allows us to open the website in a browser.

The update module only operates when using the installed version of the program which can be found in the releases section on the GitHub repository. This module uses the reqwest crate to make HTTP requests to the rl-hours-tracker repository in order to retrieve the new update from the releases section. This module has the functionality to check for any new updates, update the program, and clean up any additional files made during the update.

§Use Case

Within the website_files module, there is a public function website_files::generate_website_files, which writes the files for the website in the website directory in RlHoursFolder. This function accepts a bool value, which determines whether the option to open the website in a browser should appear when this function is called.

use rl_hours_tracker::website_files;

// This will generate the website files and prompt you with the option to open the
// webstie in a browser.
website_files::generate_website_files(true);

// This will also generate the website but will not prompt the user to open the website
// in a browser.
website_files::generate_website_files(false);

The update module has two public asynchronous functions available: update::check_for_update and update::update. The update::check_for_update function is responsible for sending a HTTP request to the repository and checking the version number of the latest release, and comparing it to the current version of the program. The update::update function is responsible updating the program by sending a HTTP request to the repository to retrieve the update zip from the latest release, and unzipping the zip files contents to replace the old program files with the newest version.

use rl_hours_tracker::update;
use tokio::runtime::Runtime;

// This creates a tokio runtime instance for running our function
let rt = Runtime::new().unwrap();

// This runs our asynchronous function which checks for an update
rt.block_on(update::check_for_update())?;

The update::check_for_update function does use the update::update function when it finds that there is a new release on the GitHub, however the update function can be used by itself in a different context if needed.

use rl_hours_tracker::update;
use tokio::runtime::Runtime;

// This creates a tokio runtime instance for running our function
let rt = Runtime::new().unwrap();

// This runs our asynchronous function which updates the program
rt.block_on(update::update())?;

Modules§

calculate_past_two
Module contains functions for caclulating the hours in the past two weeks.
update
This module is responsible for performing update operations for the Rocket League Hours Tracker binary, which can be installed through the GitHub repository releases section.
website_files
This module contains the functionality to generate the Html, CSS, and JavaScript for the Rocket League Hours Tracker website.
winit_tray_icon
This modules contains the functionality for creating the tray icon for the program and creating the thread for the event loop to run in.

Structs§

PastTwoError
Custom error for [calculate_past_two] function

Functions§

create_directory
This function creates the directories for the program. It creates a local Vec<Result> which stores fs::create_dir results.
initialize_logging
Initializes logging configuration for the program
run
This function runs the program
run_self_update
This runs the update::check_for_update function

Type Aliases§

IoResult
Type alias for Results which only return std::io::Error as its error variant.