Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error { TooSmall { needed: usize, got: usize, }, InvalidSignature, HeaderTooLarge { len: usize, max: usize, }, Utf8(Utf8Error), Xml(Error), Attr(AttrError), Ambiguous { name: String, count: usize, }, IndexOutOfRange { name: String, index: usize, count: usize, }, InvalidName { name: String, reason: &'static str, }, Io(Error), Unsupported(String), }
Expand description

Errors that can occur while parsing, reading, or writing an XISF header.

use xisf_header::{Error, Header};

let mut header = Header::new();
header.append("HISTORY", "reduced with siril").unwrap();
header.append("HISTORY", "stacked 20x300s").unwrap();

assert!(matches!(
    header.get_str("HISTORY"),
    Err(Error::Ambiguous { count: 2, .. })
));

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

TooSmall

The input was shorter than required (the 16-byte preamble, or the preamble plus the declared XML-header length).

Fields

§needed: usize

Minimum number of bytes required.

§got: usize

Number of bytes actually supplied.

§

InvalidSignature

The first eight bytes were not the XISF0100 monolithic-signature.

§

HeaderTooLarge

The declared XML-header length exceeded the 8 MiB safety cap.

Fields

§len: usize

Declared header length, in bytes.

§max: usize

Maximum accepted header length, in bytes.

§

Utf8(Utf8Error)

The XML header was not valid UTF-8.

§

Xml(Error)

The XML header was syntactically malformed.

§

Attr(AttrError)

An attribute in the XML header was malformed.

§

Ambiguous

A singular access (get/set/remove by bare name) targeted a keyword that appears more than once. Disambiguate with an (name, n) key, or use get_all/count.

Fields

§name: String

The keyword name.

§count: usize

Number of occurrences.

§

IndexOutOfRange

A Key::Nth (name, n) access referenced an occurrence index that does not exist.

Fields

§name: String

The keyword name.

§index: usize

The requested occurrence index.

§count: usize

Number of occurrences present.

§

InvalidName

A write supplied a name that is not a valid FITS keyword (≤ 8 printable ASCII characters) or valid XISF property id.

Fields

§name: String

The rejected identifier.

§reason: &'static str

Why it was rejected.

§

Io(Error)

An I/O error occurred while reading or writing a file.

§

Unsupported(String)

Header::update_file cannot safely splice this file’s XML: the common case is exactly one <Image location="attachment:OFFSET:SIZE"> element. Multiple attachments (e.g. a Thumbnail alongside the Image), no attachment at all, or a self-closing <Image/> that needs new child elements inserted are rejected rather than risking data loss.

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<AttrError> for Error

Source§

fn from(source: AttrError) -> 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<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<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> 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.