kxio/src/net/result.rs
Paul Campbell aad02be6cb
All checks were successful
Rust / build (map[name:nightly]) (push) Successful in 1m57s
Rust / build (map[name:stable]) (push) Successful in 2m12s
Release Please / Release-plz (push) Successful in 1m20s
feat(net): be more permisive in what parameters are accepted
2024-11-10 12:29:31 +00:00

30 lines
860 B
Rust

//
use derive_more::derive::From;
/// Represents a error accessing the network.
#[derive(Debug, From, derive_more::Display)]
pub enum Error {
Reqwest(reqwest::Error),
Request(String),
#[display("Unexpected request: {0}", 0.to_string())]
UnexpectedMockRequest(reqwest::Request),
RwLockLocked,
Http(http::Error),
NetIsNotAMock,
}
impl std::error::Error for Error {}
impl Clone for Error {
fn clone(&self) -> Self {
match self {
Self::Reqwest(req) => Self::Request(req.to_string()),
err => err.clone(),
}
}
}
/// Represents a success or a failure.
///
/// Any failure is related to `std::io`, a Path Traversal
/// (i.e. trying to escape the base of the `FileSystem`),
/// or attempting to use a file as a directory or /vise versa/.
pub type Result<T> = core::result::Result<T, Error>;