rocket_http/uri/error.rs
1//! Errors arising from parsing invalid URIs.
2
3use std::fmt;
4
5pub use crate::parse::uri::Error;
6
7/// The error type returned when a URI conversion fails.
8#[derive(Debug, Copy, Clone, PartialEq, Eq)]
9pub struct TryFromUriError(pub(crate) ());
10
11impl fmt::Display for TryFromUriError {
12 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13 "invalid conversion from general to specific URI variant".fmt(f)
14 }
15}
16
17/// An error interpreting a segment as a [`PathBuf`] component in
18/// [`Segments::to_path_buf()`].
19///
20/// [`PathBuf`]: std::path::PathBuf
21/// [`Segments::to_path_buf()`]: crate::uri::Segments::to_path_buf()
22#[derive(Debug, PartialEq, Eq, Clone)]
23pub enum PathError {
24 /// The segment started with the wrapped invalid character.
25 BadStart(char),
26 /// The segment contained the wrapped invalid character.
27 BadChar(char),
28 /// The segment ended with the wrapped invalid character.
29 BadEnd(char),
30}