pub struct Beatmap {Show 42 fields
pub format_version: i32,
pub audio_file: String,
pub audio_lead_in: f64,
pub preview_time: i32,
pub default_sample_bank: SampleBank,
pub default_sample_volume: i32,
pub stack_leniency: f32,
pub mode: GameMode,
pub letterbox_in_breaks: bool,
pub special_style: bool,
pub widescreen_storyboard: bool,
pub epilepsy_warning: bool,
pub samples_match_playback_rate: bool,
pub countdown: CountdownType,
pub countdown_offset: i32,
pub bookmarks: Vec<i32>,
pub distance_spacing: f64,
pub beat_divisor: i32,
pub grid_size: i32,
pub timeline_zoom: f64,
pub title: String,
pub title_unicode: String,
pub artist: String,
pub artist_unicode: String,
pub creator: String,
pub version: String,
pub source: String,
pub tags: String,
pub beatmap_id: i32,
pub beatmap_set_id: i32,
pub hp_drain_rate: f32,
pub circle_size: f32,
pub overall_difficulty: f32,
pub approach_rate: f32,
pub slider_multiplier: f64,
pub slider_tick_rate: f64,
pub background_file: String,
pub breaks: Vec<BreakPeriod>,
pub control_points: ControlPoints,
pub custom_combo_colors: Vec<Color>,
pub custom_colors: Vec<CustomColor>,
pub hit_objects: Vec<HitObject>,
}
Expand description
Fully parsed content of a .osu
file.
Fields§
§format_version: i32
§audio_file: String
§audio_lead_in: f64
§preview_time: i32
§default_sample_bank: SampleBank
§default_sample_volume: i32
§stack_leniency: f32
§mode: GameMode
§letterbox_in_breaks: bool
§special_style: bool
§widescreen_storyboard: bool
§epilepsy_warning: bool
§samples_match_playback_rate: bool
§countdown: CountdownType
§countdown_offset: i32
§bookmarks: Vec<i32>
§distance_spacing: f64
§beat_divisor: i32
§grid_size: i32
§timeline_zoom: f64
§title: String
§title_unicode: String
§artist: String
§artist_unicode: String
§creator: String
§version: String
§source: String
§beatmap_id: i32
§beatmap_set_id: i32
§hp_drain_rate: f32
§circle_size: f32
§overall_difficulty: f32
§approach_rate: f32
§slider_multiplier: f64
§slider_tick_rate: f64
§background_file: String
§breaks: Vec<BreakPeriod>
§control_points: ControlPoints
§custom_combo_colors: Vec<Color>
§custom_colors: Vec<CustomColor>
§hit_objects: Vec<HitObject>
Implementations§
source§impl Beatmap
impl Beatmap
sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
Parse a Beatmap
by providing the content of a .osu
file as a
slice of bytes.
§Example
use rosu_map::section::general::GameMode;
let bytes: &[u8] = b"[General]
Mode: 2
[Metadata]
Creator: pishifat";
let map: Beatmap = Beatmap::from_bytes(bytes)?;
assert_eq!(map.mode, GameMode::Catch);
assert_eq!(map.creator, "pishifat");
source§impl Beatmap
impl Beatmap
sourcepub fn encode_to_string(&mut self) -> IoResult<String>
pub fn encode_to_string(&mut self) -> IoResult<String>
sourcepub fn encode<W: Write>(&mut self, writer: W) -> IoResult<()>
pub fn encode<W: Write>(&mut self, writer: W) -> IoResult<()>
Encode a Beatmap
into content of a .osu
file.
§Example
In case of writing directly to a file, it is recommended to pass the
file wrapped in a BufWriter
or just use
encode_to_path
.
use std::{fs::File, io::BufWriter};
let mut map: Beatmap = /* ... */
let path = "./maps/123456.osu";
let file = File::create(path)?;
let writer = BufWriter::new(file);
map.encode(writer)?;
Encoding into a Vec<u8>
can be done by passing a mutable reference.
let mut map: Beatmap = /* ... */
let mut bytes: Vec<u8> = Vec::with_capacity(2048);
map.encode(&mut bytes)?;
// Or just use `Beatmap::encode_to_string`
let content = String::from_utf8(bytes)?;
Trait Implementations§
source§impl DecodeBeatmap for Beatmap
impl DecodeBeatmap for Beatmap
§type Error = ParseBeatmapError
type Error = ParseBeatmapError
Error type in case something goes wrong while parsing. Read more
§type State = BeatmapState
type State = BeatmapState
The parsing state which will be updated on each line and turned into
Self
at the end.source§fn parse_general(state: &mut Self::State, line: &str) -> Result<(), Self::Error>
fn parse_general(state: &mut Self::State, line: &str) -> Result<(), Self::Error>
Update the state based on a line of the
[General]
section.source§fn parse_editor(state: &mut Self::State, line: &str) -> Result<(), Self::Error>
fn parse_editor(state: &mut Self::State, line: &str) -> Result<(), Self::Error>
Update the state based on a line of the
[Editor]
section.source§fn parse_metadata(
state: &mut Self::State,
line: &str
) -> Result<(), Self::Error>
fn parse_metadata( state: &mut Self::State, line: &str ) -> Result<(), Self::Error>
Update the state based on a line of the
[Metadata]
section.source§fn parse_difficulty(
state: &mut Self::State,
line: &str
) -> Result<(), Self::Error>
fn parse_difficulty( state: &mut Self::State, line: &str ) -> Result<(), Self::Error>
Update the state based on a line of the
[Difficulty]
section.source§fn parse_events(state: &mut Self::State, line: &str) -> Result<(), Self::Error>
fn parse_events(state: &mut Self::State, line: &str) -> Result<(), Self::Error>
Update the state based on a line of the
[Events]
section.source§fn parse_timing_points(
state: &mut Self::State,
line: &str
) -> Result<(), Self::Error>
fn parse_timing_points( state: &mut Self::State, line: &str ) -> Result<(), Self::Error>
Update the state based on a line of the
[TimingPoints]
section.source§fn parse_colors(state: &mut Self::State, line: &str) -> Result<(), Self::Error>
fn parse_colors(state: &mut Self::State, line: &str) -> Result<(), Self::Error>
Update the state based on a line of the
[Colours]
section.source§fn parse_hit_objects(
state: &mut Self::State,
line: &str
) -> Result<(), Self::Error>
fn parse_hit_objects( state: &mut Self::State, line: &str ) -> Result<(), Self::Error>
Update the state based on a line of the
[HitObjects]
section.source§fn parse_variables(_: &mut Self::State, _: &str) -> Result<(), Self::Error>
fn parse_variables(_: &mut Self::State, _: &str) -> Result<(), Self::Error>
Update the state based on a line of the
[Variables]
section.source§fn parse_catch_the_beat(_: &mut Self::State, _: &str) -> Result<(), Self::Error>
fn parse_catch_the_beat(_: &mut Self::State, _: &str) -> Result<(), Self::Error>
Update the state based on a line of the
[CatchTheBeat]
section.source§fn parse_mania(_: &mut Self::State, _: &str) -> Result<(), Self::Error>
fn parse_mania(_: &mut Self::State, _: &str) -> Result<(), Self::Error>
Update the state based on a line of the
[Mania]
section.source§fn should_skip_line(line: &str) -> bool
fn should_skip_line(line: &str) -> bool
Whether a line should not be forwarded to the parsing methods.
source§impl From<BeatmapState> for Beatmap
impl From<BeatmapState> for Beatmap
source§fn from(state: BeatmapState) -> Self
fn from(state: BeatmapState) -> Self
Converts to this type from the input type.
source§impl From<Difficulty> for Beatmap
impl From<Difficulty> for Beatmap
source§fn from(difficulty: Difficulty) -> Self
fn from(difficulty: Difficulty) -> Self
Converts to this type from the input type.
source§impl From<HitObjects> for Beatmap
impl From<HitObjects> for Beatmap
source§fn from(hit_objects: HitObjects) -> Self
fn from(hit_objects: HitObjects) -> Self
Converts to this type from the input type.
source§impl From<TimingPoints> for Beatmap
impl From<TimingPoints> for Beatmap
source§fn from(timing_points: TimingPoints) -> Self
fn from(timing_points: TimingPoints) -> Self
Converts to this type from the input type.
source§impl PartialEq for Beatmap
impl PartialEq for Beatmap
impl StructuralPartialEq for Beatmap
Auto Trait Implementations§
impl RefUnwindSafe for Beatmap
impl Send for Beatmap
impl Sync for Beatmap
impl Unpin for Beatmap
impl UnwindSafe for Beatmap
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more