Struct aoe2_probe::Scenario
source · [−]pub struct Scenario {
pub versio: Token,
/* private fields */
}
Fields
versio: Token
Implementations
sourceimpl Scenario
impl Scenario
sourcepub fn from_file(filename: &str) -> Result<Self, String>
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");
sourcepub fn from_le_vec(buffer: Vec<u8>) -> Result<Self, String>
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);
sourcepub fn to_le_vec(self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn to_le_vec(self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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();
sourcepub fn to_le_export_vec(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn to_le_export_vec(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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();
sourcepub fn to_file(&self, file_path: &str, format: ExportFormat) -> Result<(), String>
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);
pub fn to_aoe2scenario(&self, file_path: &str) -> Result<(), String>
pub fn to_json_file(&self, file_path: &str) -> Result<(), String>
pub fn version(&self) -> &str
Auto Trait Implementations
impl RefUnwindSafe for Scenario
impl Send for Scenario
impl Sync for Scenario
impl Unpin for Scenario
impl UnwindSafe for Scenario
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more