Enum truck_polymesh::errors::Error

source ·
pub enum Error<V: Debug = StandardVertex> {
    OutOfRange(V),
    NoNormal,
    DifferentLengthArrays,
    IrregularArray,
    UnsortedDivision,
    FromIO(Error),
}
Expand description

Errors occurred by polygon mesh handling

Variants§

§

OutOfRange(V)

There is an index in out of range.

§Examples

use truck_polymesh::*;
use errors::Error;

let positions = vec![
    Point3::new(0.0, 0.0, 0.0),
    Point3::new(1.0, 0.0, 0.0),
    Point3::new(0.0, 1.0, 0.0),
];
let faces = Faces::from_iter(&[
    &[0, 1, 2],
    &[1, 2, 4],
]);

let res = PolygonMesh::try_new(
    StandardAttributes {
        positions,
        ..Default::default()
    },
    faces,
);
match res {
    Err(Error::OutOfRange(vertex)) => {
        assert_eq!(vertex.pos, 4);
    }
    _ => panic!("wrong result!"),
}
§

NoNormal

There are no normal in polygon mesh.

§

DifferentLengthArrays

The length of arrays of StructuredMesh is incorrect.

§

IrregularArray

The length of arrays of StructuredMesh is incorrect.

§Examples

use truck_polymesh::*;
use errors::Error;

let positions = vec![
    vec![Point3::new(0.0, 0.0, 0.0), Point3::new(1.0, 0.0, 0.0)],
    vec![Point3::new(0.0, 1.0, 0.0)],
];

match StructuredMesh::try_from_positions(positions) {
    Err(Error::IrregularArray) => {}
    _ => panic!("wrong result!"),
}
§

UnsortedDivision

The division of uv coords of StructuredMesh is not sorted.

§Examples

use truck_polymesh::*;
use errors::Error;

let positions = vec![
    vec![Point3::new(0.0, 0.0, 0.0), Point3::new(0.0, 1.0, 0.0)],
    vec![Point3::new(1.0, 0.0, 0.0), Point3::new(1.0, 1.0, 0.0)],
];

let udiv = vec![1.0, 0.0];
let vdiv = vec![0.0, 1.0];

match StructuredMesh::try_from_positions_and_uvs(positions, (udiv, vdiv)) {
    Err(Error::UnsortedDivision) => {}
    _ => panic!("wrong result!"),
}
§

FromIO(Error)

Errors caused by obj files I/O.

Trait Implementations§

source§

impl<V: Debug + Debug> Debug for Error<V>

source§

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

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

impl<V> Display for Error<V>
where V: Debug + Debug,

source§

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

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

impl<V: Debug> Error for Error<V>
where Self: Debug + Display,

source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
source§

impl<V: Debug> From<Error> for Error<V>

source§

fn from(source: Error) -> Self

Converts to this type from the input type.
source§

impl From<ParseFloatError> for Error

source§

fn from(error: ParseFloatError) -> Error

Converts to this type from the input type.
source§

impl From<ParseIntError> for Error

source§

fn from(error: ParseIntError) -> Error

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<V> Freeze for Error<V>
where V: Freeze,

§

impl<V = StandardVertex> !RefUnwindSafe for Error<V>

§

impl<V> Send for Error<V>
where V: Send,

§

impl<V> Sync for Error<V>
where V: Sync,

§

impl<V> Unpin for Error<V>
where V: Unpin,

§

impl<V = StandardVertex> !UnwindSafe for Error<V>

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

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V