Crate rman

Source
Expand description

§rman

The rman crate provides a convenient api for parsing and downloading manifest files. This format is specific to games made by Riot Games.

Crates name is derived from the 4 magic bytes at the beginning of the .manifest file, which correspond to R, M, A, N ascii characters. RMAN probably stands for Riot Manifest (or a variation of the two words).

§Usage

This crate is on crates.io. To use it, just add the dependency rman to the Cargo.toml file.

[dependencies]
rman = "0.3"

§Example: parsing a manifest file from path

Easiest way to parse a manifest file is to just provide a path to it’s location.

from_path calls File::open internally, so everything from &str to PathBuf is a valid argument.

use rman::RiotManifest;

let path = "file.manifest";

let manifest = RiotManifest::from_path(path, None)?;

assert_eq!(manifest.data.files.len(), 1);

§Example: parsing a manifest file from reader

If you read the file from another source, or you already have the file in a reader, you can instead call from_reader to parse the file.

Internally, this is what from_path calls, so the response of the two functions should be identical.

use std::fs;
use std::io::BufReader;

use rman::RiotManifest;

let path = "file.manifest";
let file = fs::File::open(path)?;
let mut reader = BufReader::new(file);

let manifest = RiotManifest::from_reader(&mut reader, None)?;

assert_eq!(manifest.data.files.len(), 1);

§Example: downloading a file

To download a specific file from a parsed manifest, you can invoke the download function on that file.

use std::fs;

use rman::{Result, RiotManifest};

#[tokio::main]
async fn main() -> Result<()> {
    let path = "file.manifest";
    let manifest = RiotManifest::from_path(path, None)?;

    let file_name = "VALORANT.exe";
    let mut file = fs::File::create(file_name)?;
    let file_to_download = manifest
        .data
        .files
        .iter()
        .find(|f| f.name == file_name)
        .expect(format!("file {file_name} does not exist in this manifest").as_str());

    let url = "https://valorant.secure.dyn.riotcdn.net/channels/public/bundles";

    file_to_download.download(&mut file, url).await?;

    assert_eq!(std::fs::read(file_name)?.len(), 4);

    Ok(())
}

§Scope

This crate:

  • reads the .manifest file, and verifies it’s a valid rman file,
  • decompresses the containing data which was compressed using zstd,
  • parses the decompressed flatbuffer data,
  • stores all of the parsed data on ManifestData,
  • combines the data into a vector of downloadable Files,
  • provides a function to download specific files.

This crate doesn’t:

  • generate a .manifest file,
  • create or parse chunks.

§Feature: default

By default, only rustls-tls is enabled.

§Feature: version_error

If enabled, throws errors on unknown manifest versions, instead of continuing and assuming it works.

§Feature: serde

If enabled, all structs in entries, as well as File will implement Serialize and Deserialize.

§Feature: native-tls

If enabled, the feature with the same name is enabled for reqwest.

§Feature: rustls-tls

If enabled, the feature with the same name is enabled for reqwest.

Modules§

entries
Collection of entries from the parsed flatbuffer schema.

Structs§

File
Single file object.
Header
File header.
ManifestData
Stores all of the flatbuffer data, as well as the parsed files.
RiotManifest
Main parser object.

Enums§

ManifestError
This enum represents all possible errors that may occur when parsing a file.

Type Aliases§

Result
Alias for a Result with the error type ManifestError.