Struct Obj

Source
pub struct Obj {
    pub data: ObjData,
    pub path: PathBuf,
}
Expand description

A struct used to store Obj data as well as its source directory used to load the referenced .mtl files.

Fields§

§data: ObjData

The data associated with this Obj file.

§path: PathBuf

The path of the parent directory from which this file was read.

It is not always set since the file may have been read from a String.

Implementations§

Source§

impl Obj

Source

pub fn save(&self, path: impl AsRef<Path>) -> Result<(), ObjError>

Save the current Obj at the given file path as well as any associated .mtl files.

If a file already exists, it will be overwritten.

Source§

impl Obj

Source

pub fn load(path: impl AsRef<Path>) -> Result<Obj, ObjError>

Load an Obj file from the given path with the default load configuration.

Source

pub fn load_with_config( path: impl AsRef<Path>, config: LoadConfig, ) -> Result<Obj, ObjError>

Load an Obj file from the given path using a custom load configuration.

Source

pub fn load_mtls(&mut self) -> Result<(), MtlLibsLoadError>

Loads the .mtl files referenced in the .obj file.

If it encounters an error for an .mtl, it appends its error to the returning Vec, and tries the rest.

Source

pub fn load_mtls_fn<R, F>(&mut self, resolve: F) -> Result<(), MtlLibsLoadError>
where R: BufRead, F: FnMut(&Path, &str) -> Result<R>,

Loads the .mtl files referenced in the .obj file with user provided loading logic.

See also load_mtls.

The provided function must take two arguments:

  • &Path - The parent directory of the .obj file
  • &str - The name of the mtllib as listed in the file.

This function allows loading .mtl files in directories different from the default .obj directory.

It must return:

  • Anything that implements io::BufRead that yields the contents of the intended .mtl file.

Trait Implementations§

Source§

impl Clone for Obj

Source§

fn clone(&self) -> Obj

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Obj

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Obj

§

impl RefUnwindSafe for Obj

§

impl Send for Obj

§

impl Sync for Obj

§

impl Unpin for Obj

§

impl UnwindSafe for Obj

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.