#[non_exhaustive]pub enum SingleParseError {
Parse(ParseError),
NoPatchesFound,
MultiplePatchesFound(usize),
}Expand description
Represents errors that can occur when parsing a diff expected to contain exactly one patch.
This enum is returned by parse_single_patch() when the input content does not
result in exactly one Patch object. It handles errors from format detection,
parsing, and patch count validation.
§Example
use mpatch::{parse_single_patch, SingleParseError};
// This diff content contains two patches, which is not allowed.
let multi_patch_diff = r#"
```diff
--- a/file1.txt
+++ b/file1.txt
@@ -1 +1 @@
-a
+b
--- a/file2.txt
+++ b/file2.txt
@@ -1 +1 @@
-c
+d
```
"#;
let result = parse_single_patch(multi_patch_diff);
assert!(matches!(result, Err(SingleParseError::MultiplePatchesFound(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.
Parse(ParseError)
An error occurred during the underlying diff parsing.
NoPatchesFound
The provided diff content did not contain any valid patches (Markdown blocks, Unified Diffs, or Conflict Markers).
MultiplePatchesFound(usize)
The provided diff content contained patches for more than one file, which is not
supported by this function. Use parse_diffs() for multi-file operations.
Trait Implementations§
Source§impl Debug for SingleParseError
impl Debug for SingleParseError
Source§impl Display for SingleParseError
impl Display for SingleParseError
Source§impl Error for SingleParseError
impl Error for SingleParseError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<ParseError> for SingleParseError
impl From<ParseError> for SingleParseError
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Converts to this type from the input type.
Source§impl PartialEq for SingleParseError
impl PartialEq for SingleParseError
impl StructuralPartialEq for SingleParseError
Auto Trait Implementations§
impl Freeze for SingleParseError
impl RefUnwindSafe for SingleParseError
impl Send for SingleParseError
impl Sync for SingleParseError
impl Unpin for SingleParseError
impl UnsafeUnpin for SingleParseError
impl UnwindSafe for SingleParseError
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> 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