XFile

Struct XFile 

Source
pub struct XFile {
    pub templates: HashMap<String, Template>,
    pub data_objects: Vec<DataValue>,
}

Fields§

§templates: HashMap<String, Template>§data_objects: Vec<DataValue>

Implementations§

Source§

impl XFile

Source

pub fn read(data: &[u8]) -> Result<Self, XFileError>

Examples found in repository?
examples/read.rs (line 7)
3fn main() -> Result<(), XFileError> {
4    let mut args = std::env::args();
5    let _ = args.next();
6    let contents = std::fs::read(args.next().expect("No x file provided")).unwrap();
7    let x_mesh = XFile::read(&contents)?;
8    println!("{:#?}", x_mesh);
9    Ok(())
10}
More examples
Hide additional examples
examples/2obj.rs (line 14)
8fn main() -> Result<(), XFileError> {
9    let input_path = std::env::args().nth(1).expect("Usage: <program> input.x");
10    let output_path = input_path.replace(".x", ".obj");
11    let mtl_path = input_path.replace(".x", ".mtl");
12
13    let contents = std::fs::read(&input_path).expect("Failed to read .x file");
14    let xfile = XFile::read(&contents)?;
15
16    write_obj(&xfile, &output_path, &mtl_path).expect("Failed to write .obj");
17    println!("Converted to: {}", output_path);
18
19    Ok(())
20}

Trait Implementations§

Source§

impl Debug for XFile

Source§

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

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

impl Default for XFile

Source§

fn default() -> XFile

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

Auto Trait Implementations§

§

impl Freeze for XFile

§

impl RefUnwindSafe for XFile

§

impl Send for XFile

§

impl Sync for XFile

§

impl Unpin for XFile

§

impl UnwindSafe for XFile

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

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.