#[non_exhaustive]pub enum OneShotError {
Parse(ParseError),
Apply(StrictApplyError),
NoPatchesFound,
MultiplePatchesFound(usize),
}Expand description
Represents errors that can occur during the high-level patch_content_str() operation.
This enum consolidates all possible failures from the one-shot workflow, including parsing errors, finding the wrong number of patches, or failures during the strict application process.
§Example
use mpatch::{patch_content_str, ApplyOptions, OneShotError};
// This diff content contains two patches, which is not allowed by `patch_content_str`.
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 options = ApplyOptions::new();
let result = patch_content_str(multi_patch_diff, Some("a\n"), &options);
assert!(matches!(result, Err(OneShotError::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 while parsing the diff content.
Apply(StrictApplyError)
An error occurred while applying the patch. This includes partial applications.
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 simplified function. Use parse_diffs() and
apply_patches_to_dir() for multi-file operations.
Trait Implementations§
Source§impl Debug for OneShotError
impl Debug for OneShotError
Source§impl Display for OneShotError
impl Display for OneShotError
Source§impl Error for OneShotError
impl Error for OneShotError
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 OneShotError
impl From<ParseError> for OneShotError
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Converts to this type from the input type.
Source§impl From<StrictApplyError> for OneShotError
impl From<StrictApplyError> for OneShotError
Source§fn from(source: StrictApplyError) -> Self
fn from(source: StrictApplyError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for OneShotError
impl !RefUnwindSafe for OneShotError
impl Send for OneShotError
impl Sync for OneShotError
impl Unpin for OneShotError
impl UnsafeUnpin for OneShotError
impl !UnwindSafe for OneShotError
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