Skip to main content

HmlError

Enum HmlError 

Source
pub enum HmlError<P>
where P: Posn,
{ IoError { span: Span<P>, source: Error, }, MarkupError { span: Span<P>, source: MarkupError, }, ExpectedTagName { span: Span<P>, }, ExpectedWhitespaceAfterTag { span: Span<P>, }, UnexpectedCharacter { span: Span<P>, ch: char, }, UnexpectedTagIndent { span: Span<P>, depth: usize, }, BeyondEndOfTokens, UnexpectedAttribute { span: Span<P>, attr: String, }, UnexpectedNewlineInQuotedString { span: Span<P>, }, ExpectedEquals { span: Span<P>, ch: char, }, UnexpectedEOF { span: Span<P>, }, }
Expand description

HmlError represents an error from the UTF-8 character reader, either an IO error from the reader or a malformed UTF-8 encoded set of bytes.

Variants§

§

IoError

An IO error

Fields

§span: Span<P>

Span of the error

§source: Error

Error

§

MarkupError

A markup error

Fields

§span: Span<P>

Span of the error

§source: MarkupError

Error

§

ExpectedTagName

Expected a tag name after hashes

Fields

§span: Span<P>

Span of the error

§

ExpectedWhitespaceAfterTag

Expect whitespace after a tag

Fields

§span: Span<P>

Span of the error

§

UnexpectedCharacter

An unexpected character

Fields

§span: Span<P>

Span of the error

§ch: char

Character

§

UnexpectedTagIndent

Expected a depth of N or N+1

Fields

§span: Span<P>

Span of the error

§depth: usize

Depth

§

BeyondEndOfTokens

Iterated beyond the end of the reader stream

§

UnexpectedAttribute

Attribute provided where an attribute was not expected

Fields

§span: Span<P>

Span of the error

§attr: String

Attribute

§

UnexpectedNewlineInQuotedString

Newline in a quoted string

Fields

§span: Span<P>

Span of the error

§

ExpectedEquals

Expected an ‘=’ for an attribute but got something else

Fields

§span: Span<P>

Span of the error

§ch: char

Character

§

UnexpectedEOF

EOF when it was not expected

Fields

§span: Span<P>

Span of the error

Implementations§

Source§

impl<P> HmlError<P>
where P: Posn,

Source

pub fn unexpected_eof<T>(start: &P, end: &P) -> HmlResult<T, P>

Return an unexpected_eof error at the specified positions

Source

pub fn unexpected_character<T>(start: &P, end: &P, ch: char) -> HmlResult<T, P>

Return an unexpected_character error at the specified positions

Source

pub fn unexpected_newline_in_string<T>(start: &P, end: &P) -> HmlResult<T, P>

Return an unexpected newline error

Source

pub fn expected_equals<T>(start: &P, end: &P, ch: char) -> HmlResult<T, P>

Return an error indicating an expected character, but got a different character

Source

pub fn no_more_events<T>() -> HmlResult<T, P>

Return an error indicating a read beyond the end of the stream

Source

pub fn unexpected_tag_indent<T>(span: Span<P>, depth: usize) -> HmlResult<T, P>

Return an unexpected_tag_indent error over the specified span

Source

pub fn unexpected_attribute<T>( span: Span<P>, prefx: &str, name: &str, ) -> HmlResult<T, P>

Return an unexpected_attribute eror over the given span

Source

pub fn io_error(span: Span<P>, source: Error) -> Self

An IO error

Source

pub fn of_io_result<T>(span: Span<P>, r: Result<T, Error>) -> HmlResult<T, P>

Map a io result over a span to a HmlError result

Source§

impl<P> HmlError<P>
where P: Posn,

Source

pub fn span(&self) -> Option<&Span<P>>

Borrow a span if it has one

Source

pub fn map_markup_error<T>( result: MarkupResult<T>, span: &Span<P>, ) -> HmlResult<T, P>

Map a MarkupResult to an HmlResult; this passes an Ok value through unchanged, but it maps an Err to an HmlResult::MarkupError with the provided span

Trait Implementations§

Source§

impl<P> Debug for HmlError<P>
where P: Posn + Debug,

Source§

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

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

impl<P> Display for HmlError<P>
where P: Posn,

Source§

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

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

impl<P> Error for HmlError<P>
where P: Posn, 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<P> LexerError<P> for HmlError<P>
where P: Posn,

Source§

fn failed_to_parse(posn: P, ch: char) -> Self

Return an error indicating that a bad character (could not be matched for a token) has occurred at the position indicated by the state

Auto Trait Implementations§

§

impl<P> Freeze for HmlError<P>
where P: Freeze,

§

impl<P> !RefUnwindSafe for HmlError<P>

§

impl<P> Send for HmlError<P>
where P: Send,

§

impl<P> Sync for HmlError<P>
where P: Sync,

§

impl<P> Unpin for HmlError<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for HmlError<P>
where P: UnsafeUnpin,

§

impl<P> !UnwindSafe for HmlError<P>

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.