[][src]Struct elma::rec::Replay

pub struct Replay {
    pub flag_tag: bool,
    pub link: u32,
    pub level: String,
    pub path: Option<PathBuf>,
    pub rides: Vec<Ride>,
}

Replay struct

Fields

flag_tag: bool

Whether replay is flag-tag or not.

link: u32

Random number to link with level file.

level: String

Full level filename.

path: Option<PathBuf>

Path to file.

rides: Vec<Ride>

Rides of players.

Methods

impl Replay[src]

pub fn is_multi(&self) -> bool[src]

Returns whether this is a multiplayer replay.

impl Replay[src]

pub fn new() -> Self[src]

Return a new Replay struct.

Examples

let rec = elma::rec::Replay::new();

pub fn load<P: Into<PathBuf>>(path: P) -> Result<Self, ElmaError>[src]

Loads a replay file and returns a Replay struct.

Examples

let rec = Replay::load("tests/assets/replays/test_1.rec").unwrap();

pub fn from_bytes<B: AsRef<[u8]>>(buffer: B) -> Result<Self, ElmaError>[src]

Load a replay from bytes.

Examples

let rec = Replay::from_bytes(&[0,1,2]).unwrap();

pub fn to_bytes(&self) -> Result<Vec<u8>, ElmaError>[src]

Returns replay data as a buffer of bytes.

pub fn save<P: Into<PathBuf>>(&mut self, path: P) -> Result<(), ElmaError>[src]

Save replay as a file.

pub fn get_time_ms(&self) -> (usize, bool)[src]

Get time of replay. Returns tuple with milliseconds and whether replay was finished, caveat being that there is no way to tell if a replay was finished or not just from the replay file with a 100% certainty. Merely provided for convenience.

Examples

let replay = Replay::load("tests/assets/replays/test_1.rec").unwrap();
let (time, finished) = replay.get_time_ms();
assert_eq!(time, 14649);
assert_eq!(finished, true);

pub fn get_time_hs(&self) -> (usize, bool)[src]

Get time of replay. Returns tuple with hundredths and whether replay was finished, caveat being that there is no way to tell if a replay was finished or not just from the replay file with a 100% certainty. Merely provided for convinience.

Examples

let replay = Replay::load("tests/assets/replays/test_1.rec").unwrap();
let (time, finished) = replay.get_time_hs();
assert_eq!(time, 1464);
assert_eq!(finished, true);

Trait Implementations

impl Default for Replay[src]

impl PartialEq<Replay> for Replay[src]

impl Debug for Replay[src]

Auto Trait Implementations

impl Send for Replay

impl Sync for Replay

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.