Skip to main content

BmsTableHeader

Struct BmsTableHeader 

Source
#[non_exhaustive]
pub struct BmsTableHeader { pub name: String, pub symbol: String, pub data_url: String, pub tag: Option<String>, pub mode: Option<String>, pub course: CourseGroup, pub level_order: Vec<String>, pub extra: BTreeMap<String, Value>, }
Expand description

BMS header information.

Strictly parses common fields and preserves unrecognized fields in extra for forward compatibility.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: String

Table name, e.g. “Satellite”

§symbol: String

Table symbol, e.g. “sl”

§data_url: String

URL of chart data file (preserves the original string from header JSON)

§tag: Option<String>

Tag label text; use effective_tag to get the spec-mandated fallback to symbol when this is None.

§mode: Option<String>

Play mode hint; same semantics as bmson’s mode_hint

§course: CourseGroup

Course information, preserving the original JSON nesting shape.

Supports flat arrays ("course": [{...}]) and arbitrarily nested arrays ("course": [[{...}]], "course": [[{...}], [{...}]], etc.). Deserialized as a CourseGroup tree.

§level_order: Vec<String>

Difficulty level order containing numbers and strings

§extra: BTreeMap<String, Value>

Extra data (unrecognized fields from header JSON)

Implementations§

Source§

impl BmsTableHeader

Source

pub const fn new(name: String, symbol: String, data_url: String) -> Self

Creates a new BmsTableHeader with the given required fields and defaults for everything else.

Source

pub fn level_index(&self, level: &str) -> Option<usize>

Returns the index of a level in level_order, or None if not found.

This is useful for comparing difficulty levels: a lower index means an easier level.

Note: This performs a linear scan (O(n)) on each call. For repeated lookups across many chart items, consider building a HashMap<&str, usize> from level_order once.

§Example
let mut header = BmsTableHeader::new(
    "Test".into(),
    "t".into(),
    "d.json".into(),
);
header.level_order = vec!["1".into(), "2".into(), "3".into()];
assert_eq!(header.level_index("2"), Some(1));
assert_eq!(header.level_index("4"), None);
Source

pub fn effective_tag(&self) -> &str

Returns the effective tag, falling back to symbol when tag is None.

Per the BMS difficulty table spec, the tag field should fall back to symbol when absent. This method implements that behavior.

§Example
let header = BmsTableHeader::new("Table".into(), "sl".into(), "d.json".into());
assert_eq!(header.effective_tag(), "sl");

Trait Implementations§

Source§

impl Clone for BmsTableHeader

Source§

fn clone(&self) -> BmsTableHeader

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BmsTableHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BmsTableHeader

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for BmsTableHeader

Source§

fn eq(&self, other: &BmsTableHeader) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for BmsTableHeader

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for BmsTableHeader

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.