pub enum SearchError {
IoError(Error),
SendError(String),
ThreadError(String),
PathError(String),
}Expand description
Error type representing various failures that can occur during search operations.
This enum encapsulates different types of errors that might occur during file analysis or directory traversal, including I/O errors, thread communication errors, and filepath-related errors.
Variants§
IoError(Error)
Represents underlying I/O errors from the standard library.
This variant wraps std::io::Error and is commonly used for file system
operations that fail, such as reading directories or files.
SendError(String)
Represents errors that occur when sending data between threads.
Contains a string description of what went wrong during the send operation.
ThreadError(String)
Represents errors related to thread operation failures.
Contains a string description of what went wrong with thread handling, such as join handle errors or thread panic information.
PathError(String)
Represents errors related to invalid or problematic file paths.
Contains a string description of what went wrong with the path, such as invalid characters or path syntax errors.
Trait Implementations§
Source§impl Debug for SearchError
impl Debug for SearchError
Source§impl Display for SearchError
impl Display for SearchError
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the error for display purposes.
Provides a human-readable error message that includes both the error type and its associated details.
§Examples
use ferris_files::errors::SearchError;
let err = SearchError::PathError("Invalid path character".to_string());
assert_eq!(format!("{}", err), "Path error: Invalid path character");Source§impl Error for SearchError
impl Error for SearchError
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.
Currently only returns a source for SearchError::IoError, as it’s the only
variant that wraps another error type implementing std::error::Error.
§Returns
Some(&std::io::Error)forIoErrorvariantNonefor all other variants
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Error> for SearchError
impl From<Error> for SearchError
Source§fn from(err: Error) -> Self
fn from(err: Error) -> Self
Converts a std::io::Error into a SearchError.
This implementation allows for easy conversion of standard I/O errors
into our custom error type using the ? operator.
§Examples
use std::fs::File;
use ferris_files::errors::SearchError;
fn read_file() -> Result<(), SearchError> {
let _file = File::open("nonexistent.txt")?; // Will convert io::Error to SearchError
Ok(())
}
assert!(matches!(read_file(), Err(SearchError)));Auto Trait Implementations§
impl !RefUnwindSafe for SearchError
impl !UnwindSafe for SearchError
impl Freeze for SearchError
impl Send for SearchError
impl Sync for SearchError
impl Unpin for SearchError
impl UnsafeUnpin for SearchError
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
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>
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>
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