MixPackage

Struct MixPackage 

Source
pub struct MixPackage {
    pub game: CncGame,
    pub files: HashMap<String, Vec<u8>>,
}
Expand description

MIX package

Fields§

§game: CncGame

The game version of the MIX package

§files: HashMap<String, Vec<u8>>

A map of file names to file data

Implementations§

Source§

impl MixPackage

Source

pub fn load(mix_path: &Path, db: &MixDatabase) -> Result<Self, Ra2Error>

§Arguments
  • input:

returns: Result<XccPackage, MixError>

§Examples
Source

pub fn decode(mix_data: &[u8], db: &MixDatabase) -> Result<Self, Ra2Error>

Reads a MIX file and returns a map of filenames to file data

§Arguments
  • input:

returns: Result<XccPackage, MixError>

§Examples
Source§

impl MixPackage

Source

pub fn save(self, output: &Path) -> Result<usize, Ra2Error>

§Arguments
  • output:
§Examples
Source

pub fn dump(self, output: &Path) -> Result<usize, Ra2Error>

Source

pub unsafe fn dump_unchecked(self, output: &Path) -> Result<usize, Ra2Error>

Source

pub fn encode(self) -> Result<Vec<u8>, Ra2Error>

§Arguments
  • output:
§Examples
Source§

impl MixPackage

Source

pub fn add_any(&mut self, name: String, data: Vec<u8>)

Add any file to the MIX package, no matter if it is valid or not.

§Arguments
  • name: the file name with extension
  • data: the file bytes
§Examples
let mut mix = ra2_mix::MixPackage::default();
mix.add_any("hello.txt".to_string(), b"Hello, World!".to_vec());
Source

pub fn add_file(&mut self, data: &Path) -> Result<usize, Ra2Error>

Add a file from filesystem to the package

§Arguments
  • data - Path to the file to add
§Returns

Size of the added file in bytes on success, or error if file not found

§Examples
use ra2_mix::MixPackage;
use std::path::Path;

let mut package = MixPackage::default();
package.add_file(Path::new("test.txt")).unwrap();

Trait Implementations§

Source§

impl Debug for MixPackage

Source§

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

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

impl Default for MixPackage

Source§

fn default() -> MixPackage

Returns the “default value” for a type. Read more

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more