Struct aoe2_probe::Scenario

source ·
pub struct Scenario {
    pub versio: Token,
    /* private fields */
}

Fields§

§versio: Token

Implementations§

source§

impl Scenario

source

pub fn from_file(filename: &str) -> Result<Self, String>

Read scenario data from the given file. Please check the github homepage for the version support status. Generally, ver.1.46 and above are well supported.

§Examples
use aoe2_probe::Scenario;
let scenario = Scenario::from_file("./resources/chapter_1.aoe2scenario");
source

pub fn from_le_vec(buffer: Vec<u8>) -> Result<Self, String>

Read scenario data from the given little endian buffer.

§Examples
use aoe2_probe::Scenario;
//Encode a scenario to a little endian vector of uint8
let source_scenario = Scenario::from_file("./resources/chapter_1.aoe2scenario").unwrap();
let buffer = source_scenario.to_le_export_vec();

//Decode a scenario from a little endian vector of uint8
let scenario = Scenario::from_le_vec(buffer);
source

pub fn from_versio(versio: &Token) -> Result<Self, String>

source

pub fn to_le_vec(self) -> Vec<u8>

Encode a scenario struct to little endian vector of uint8 If you want to generate an .aoe2scenario file, then this function are not recommended. The whole .aoe2scenario except file header part are compressed. The bytes generated by this function are raw uncompressed. See function to_export_le_vec for compressed bytes.

§Examples
use aoe2_probe::Scenario;
//Encode a scenario to a little endian vector of uint8
let source_scenario = Scenario::from_file("./resources/chapter_1.aoe2scenario").unwrap();
let buffer = source_scenario.to_le_vec();
source

pub fn to_le_export_vec(&self) -> Vec<u8>

Encode a scenario struct to little endian vector of uint8 that can be read by AoE2 DE

§Examples
use aoe2_probe::Scenario;
//Encode a scenario to a little endian vector of uint8
let source_scenario = Scenario::from_file("./resources/chapter_1.aoe2scenario").unwrap();
let buffer = source_scenario.to_le_export_vec();
source

pub fn to_file( &self, file_path: &str, format: ExportFormat ) -> Result<(), String>

Save the given scenario to the given path. The path will be created if not existed.

§Examples
use aoe2_probe::{Scenario, ExportFormat};
let source_scenario = Scenario::from_file("./resources/chapter_1.aoe2scenario").unwrap();
let buffer = source_scenario.to_file("./resources/temp.aoe2scenario", ExportFormat::AoE2Scenario);
source

pub fn to_aoe2scenario(&self, file_path: &str) -> Result<(), String>

source

pub fn to_json_file(&self, file_path: &str) -> Result<(), String>

source

pub fn version(&self) -> &str

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.