Crate bms_table

Crate bms_table 

Source
Expand description

BMS difficulty table fetching and parsing

Provides building a complete BMS difficulty table data structure from a web page or a header JSON, covering the header, courses, trophies, and chart items. Combined with feature flags, it implements network fetching and HTML parsing, suitable for CLI tools, server programs, or data-processing pipelines.

§Feature overview

  • Parse header JSON into BmsTableHeader, preserving unrecognized fields in extra for forward compatibility;
  • Parse chart data into BmsTableData, supporting a plain array of ChartItem structure;
  • Courses automatically convert md5/sha256 lists into chart items, filling missing level with “0”;
  • Extract the header JSON URL from HTML <meta name="bmstable">;
  • One-stop network fetching APIs (web page → header JSON → chart data);
  • Support fetching a list of difficulty tables into BmsTableList. An example source page.

§Feature flags

  • serde: enable serialization/deserialization support for types (enabled by default).
  • scraper: enable HTML parsing and bmstable header URL extraction (enabled by default; implicitly enabled by reqwest).
  • reqwest: enable the network fetching implementation (enabled by default; requires the tokio runtime).

§Quick start (network fetching)

use bms_table::fetch::reqwest::{fetch_table, make_lenient_client};

let client = make_lenient_client()?;
let table = fetch_table(&client, "https://stellabms.xyz/sl/table.html").await?;
println!("{}: {} charts", table.header.name, table.data.charts.len());

§Offline usage (parse JSON directly)

use bms_table::{BmsTable, BmsTableHeader, BmsTableData};

let header_json = r#"{ "name": "Test", "symbol": "t", "data_url": "charts.json", "course": [], "level_order": [] }"#;
let data_json = r#"[]"#;
let header: BmsTableHeader = serde_json::from_str(header_json)?;
let data: BmsTableData = serde_json::from_str(data_json)?;
let _table = BmsTable { header, data };

§Example: fetch table list

use bms_table::fetch::reqwest::{fetch_table_list, make_lenient_client};
let client = make_lenient_client()?;
let indexes = fetch_table_list(&client, "https://example.com/table_index.json").await?;
assert!(!indexes.is_empty());

Hint: enabling the reqwest feature implicitly enables scraper to support locating the bmstable header URL from page content.

Modules§

deserde
Deserialization implementation module
fetchscraper
Data fetching and HTML parsing helpers

Structs§

BmsTable
Top-level BMS difficulty table data structure.
BmsTableData
BMS table data.
BmsTableHeader
BMS header information.
BmsTableInfo
BMS difficulty table list item.
BmsTableList
Wrapper type for the list of BMS difficulty tables.
BmsTableRaw
Complete set of original JSON strings.
ChartItem
Chart data item.
CourseInfo
Course information.
Trophy
Trophy information.