Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 17 variants Open { path: PathBuf, source: Error, }, Create { path: PathBuf, source: Error, }, Write { what: &'static str, path: Option<PathBuf>, source: Error, }, Parse { what: &'static str, path: Option<PathBuf>, source: Box<dyn Error + Send + Sync>, }, Serialize { what: &'static str, source: Box<dyn Error + Send + Sync>, }, WrongRoot { what: &'static str, expected: &'static str, found: String, }, MissingRoot { what: &'static str, }, MissingAttribute { element: &'static str, attribute: &'static str, }, InvalidNumber { context: &'static str, value: String, }, NonFiniteNumber { context: &'static str, value: String, }, IncompletePosition { context: &'static str, value: String, }, TooManyCoordinates { context: &'static str, value: String, }, AmbiguousBool, InvalidBoundary { value: String, }, InvalidColor { value: String, }, InvalidClockTime { value: String, }, ConflictingAttributes { element: &'static str, first: &'static str, second: &'static str, },
}
Expand description

Anything that can go wrong reading or writing a SUMO file.

The variants split into three groups: I/O against the file itself, well-formedness of the XML and its root element, and the SUMO-specific value encodings each format’s schema_mapper interprets (positions, shapes, booleans, …). Only the last group is specific to this crate; the first two would apply to any XML reader.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Open

The input file could not be opened.

Fields

§path: PathBuf
§source: Error
§

Create

The output file could not be created.

Fields

§path: PathBuf
§source: Error
§

Write

Writing to the output failed partway through.

path is None when writing to a caller-supplied sink (write_network_to and friends) rather than to a file this crate opened itself. Code span, not an intra-doc link: this module is compiled under every feature combination, and write_network_to only exists under net + write — see the crate docs.

Fields

§what: &'static str
§source: Error
§

Parse

The document isn’t well-formed XML, or doesn’t fit the format’s schema.

The underlying error is boxed rather than named: it comes from xsd-parser-types, which lib.rs deliberately keeps out of this crate’s public API. std::error::Error::source still reaches it for anyone who wants the detail.

Fields

§what: &'static str
§source: Box<dyn Error + Send + Sync>
§

Serialize

The value could not be serialized to XML. Boxed for the same reason as Self::Parse.

Fields

§what: &'static str
§source: Box<dyn Error + Send + Sync>
§

WrongRoot

The document is well-formed but rooted at the wrong element — a .rou.xml handed to read_network, say. (Code span rather than a link, for the same reason as Self::Write above.)

Worth its own variant because nothing else catches it: xsd-parser generates deserializers for XSD types, not elements, and most SUMO schemas make their content optional, so an unrelated document otherwise parses into an empty, plausible-looking value. See xml::RootRecordingReader.

Fields

§what: &'static str
§expected: &'static str
§found: String
§

MissingRoot

The document has no root element at all (it is empty, or contains only a declaration and comments).

Fields

§what: &'static str
§

MissingAttribute

An attribute the format requires in practice was absent. Only raised where a real SUMO writer always emits the attribute even though the XSD marks it optional — see net::domain::Location.

Fields

§element: &'static str
§attribute: &'static str
§

InvalidNumber

A number didn’t parse. context names the attribute it came from ("junction x coordinate", …).

Fields

§context: &'static str
§value: String
§

NonFiniteNumber

A number parsed but was NaN or an infinity, which SUMO’s floatType pattern excludes and which would poison every computation downstream — see sumo::parse_finite.

Fields

§context: &'static str
§value: String
§

IncompletePosition

A position had fewer than the two coordinates SUMO’s positionType requires.

Fields

§context: &'static str
§value: String
§

TooManyCoordinates

A position had more than the three coordinates SUMO’s positionType allows.

Fields

§context: &'static str
§value: String
§

AmbiguousBool

SUMO’s boolType allows "x" and "-", the “unspecified” marker its configuration options use. Neither has a binary meaning, so they are an error rather than a silent false.

§

InvalidBoundary

A locationType boundary didn’t have exactly the four components "minX,minY,maxX,maxY" needs.

Fields

§value: String
§

InvalidColor

A colorType in its numeric form didn’t have 3 ("r,g,b") or 4 ("r,g,b,a") components.

Fields

§value: String
§

InvalidClockTime

A timeType in its clock form didn’t have 3 ("H:M:S") or 4 ("H:M:S:MS") components.

Fields

§value: String
§

ConflictingAttributes

Two attributes SUMO treats as alternatives were both set — an e2Detector with both lane and lanes, for instance.

Fields

§element: &'static str
§first: &'static str
§second: &'static str

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

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<X> AsAny for X
where X: 'static,

Source§

fn into_any(self: Box<X>) -> Box<dyn Any>

Convert the boxed object into a boxed any.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Get a reference to the current object as Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Get a mutable reference to the current object as Any.
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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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.