Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 14 variants Io(Error), Json(Error), Utf8(Utf8Error), Decode { key: String, message: String, }, Encode { key: String, message: String, }, MissingKey { wanted: Vec<String>, available: Vec<String>, }, DuplicateKey { key: String, sample_key: String, }, Security(String), Subprocess(String), Format(String), Unsupported(String), Value(String), Empty(String), Context { context: String, source: Box<Error>, },
}
Expand description

The error type used throughout the webdataset crates.

Errors carry enough context to be reported usefully by the pluggable Handler implementations: the URL of the shard and the key of the sample are attached as they travel up the pipeline.

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.
§

Io(Error)

Available on crate feature std only.

An underlying I/O failure.

§

Json(Error)

Available on crate feature json only.

A JSON value could not be parsed or serialized.

§

Utf8(Utf8Error)

Bytes that were expected to be UTF-8 were not.

§

Decode

A sample field could not be decoded.

Fields

§key: String

The field (file extension) that failed to decode.

§message: String

A human readable description of the failure.

§

Encode

A sample field could not be encoded for writing.

Fields

§key: String

The field that failed to encode.

§message: String

A human readable description of the failure.

§

MissingKey

A required key was not present in a sample.

Fields

§wanted: Vec<String>

The key(s) that were looked up.

§available: Vec<String>

The keys the sample actually had.

§

DuplicateKey

The same key occurred twice while grouping files into a sample.

Fields

§key: String

The duplicated field name.

§sample_key: String

The key of the sample being assembled.

§

Security(String)

An operation was refused because secure mode is enabled.

§

Subprocess(String)

A subprocess used to open a URL failed.

§

Format(String)

Malformed input data (bad archive, bad header, bad brace expression).

§

Unsupported(String)

The requested functionality is not available in this build.

§

Value(String)

A value had the right shape but the wrong contents.

§

Empty(String)

A pipeline stage that was declared non-empty produced no data.

§

Context

An error with additional context attached.

Fields

§context: String

What was being attempted.

§source: Box<Error>

The underlying error.

Implementations§

Source§

impl Error

Source

pub fn format(message: impl Display) -> Self

Build an Error::Format from anything printable.

Source

pub fn value(message: impl Display) -> Self

Build an Error::Value from anything printable.

Source

pub fn unsupported(message: impl Display) -> Self

Build an Error::Unsupported from anything printable.

Source

pub fn decode(key: impl Into<String>, message: impl Display) -> Self

Build an Error::Decode for the given field.

Source

pub fn encode(key: impl Into<String>, message: impl Display) -> Self

Build an Error::Encode for the given field.

Source

pub fn context(self, context: impl Display) -> Self

Attach context to an error, mirroring the way the Python implementation appends the offending URL to exn.args.

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
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Utf8Error> for Error

Source§

fn from(source: Utf8Error) -> Self

Converts to this type from the input type.

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<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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CustomValue for T
where T: Any + Debug + Send + Sync,

Source§

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

Upcast so callers can downcast to the concrete type.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.