#[non_exhaustive]pub struct FormatError {
pub kind: FormatErrorKind,
pub position: Option<Position>,
pub message: String,
}Expand description
A document of one format that cannot be read or written: what kind of trouble it is, where the reader stood, and the reader’s own words.
Its Display is the message alone; the Error variant holding it
names the format, and holds it boxed, so that the crate’s every
Result is no wider for it.
use music21::error::{FormatErrorKind, Position};
let error = music21::mei::from_mei("<mei><music").unwrap_err();
let read = error.format_error().unwrap();
assert_eq!(read.kind, FormatErrorKind::Malformed);
assert_eq!(error.position(), Some(&Position::line(1).with_column(12)));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.kind: FormatErrorKindWhat kind of trouble it is.
position: Option<Position>Where in the document the reader was, where it knows.
message: StringWhat the reader or writer says went wrong.
Implementations§
Source§impl FormatError
impl FormatError
Sourcepub fn new(kind: FormatErrorKind, message: impl Into<String>) -> Self
pub fn new(kind: FormatErrorKind, message: impl Into<String>) -> Self
An error of kind saying message, at no position yet.
Sourcepub fn with_position(self, position: Position) -> Self
pub fn with_position(self, position: Position) -> Self
The same error, at position.
Trait Implementations§
Source§impl Clone for FormatError
impl Clone for FormatError
Source§impl Debug for FormatError
impl Debug for FormatError
Source§impl Display for FormatError
impl Display for FormatError
impl Eq for FormatError
Source§impl PartialEq for FormatError
impl PartialEq for FormatError
impl StructuralPartialEq for FormatError
Auto Trait Implementations§
impl Forget for FormatError
impl Freeze for FormatError
impl RefUnwindSafe for FormatError
impl Send for FormatError
impl Sync for FormatError
impl Unpin for FormatError
impl UnsafeUnpin for FormatError
impl UnwindSafe for FormatError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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