pub enum ParsePatternError {
InvalidRegex {
pattern: Arc<str>,
source: Error,
},
InvalidGlob {
source: Error,
},
}Expand description
普通模式解析错误
§示例
use dhttp_access::pattern::{NormalPattern, ParsePatternError};
// 无效的正则表达式
let result: Result<NormalPattern, _> = "~ [".parse();
assert!(matches!(result, Err(ParsePatternError::InvalidRegex { .. })));
// 注意:大多数 glob 模式实际上是有效的,这里只是示例
// 实际的 InvalidGlob 错误比较难构造,通常发生在内部处理时Variants§
InvalidRegex
无效的正则表达式
§Examples
use dhttp_access::pattern::{NormalPattern, ParsePatternError};
let result: Result<NormalPattern, _> = "~ [invalid".parse();
assert!(matches!(result, Err(ParsePatternError::InvalidRegex { .. })));
let result: Result<NormalPattern, _> = "~* (?P<invalid".parse();
assert!(matches!(result, Err(ParsePatternError::InvalidRegex { .. })));InvalidGlob
无效的 Glob 模式
§Examples
use dhttp_access::pattern::{NormalPattern, ParsePatternError};
// 注意:实际上多数 glob 模式是有效的,这里用简化的示例
let result = NormalPattern::new("***/invalid");
// 由于这个例子可能不会失败,我们使用 expect 来说明预期的错误类型
// assert!(matches!(result, Err(ParsePatternError::InvalidGlob { .. })));Trait Implementations§
Source§impl Clone for ParsePatternError
impl Clone for ParsePatternError
Source§fn clone(&self) -> ParsePatternError
fn clone(&self) -> ParsePatternError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ParsePatternError
impl Debug for ParsePatternError
Source§impl Display for ParsePatternError
impl Display for ParsePatternError
Source§impl Error for ParsePatternError
impl Error for ParsePatternError
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 ErrorCompat for ParsePatternError
impl ErrorCompat for ParsePatternError
Source§fn iter_chain(&self) -> ChainCompat<'_, '_>where
Self: AsErrorSource,
fn iter_chain(&self) -> ChainCompat<'_, '_>where
Self: AsErrorSource,
Returns an iterator for traversing the chain of errors,
starting with the current error
and continuing with recursive calls to
Error::source. Read moreAuto Trait Implementations§
impl Freeze for ParsePatternError
impl RefUnwindSafe for ParsePatternError
impl Send for ParsePatternError
impl Sync for ParsePatternError
impl Unpin for ParsePatternError
impl UnsafeUnpin for ParsePatternError
impl UnwindSafe for ParsePatternError
Blanket Implementations§
Source§impl<T> AsErrorSource for Twhere
T: Error + 'static,
impl<T> AsErrorSource for Twhere
T: Error + 'static,
Source§fn as_error_source(&self) -> &(dyn Error + 'static)
fn as_error_source(&self) -> &(dyn Error + 'static)
For maximum effectiveness, this needs to be called as a method
to benefit from Rust’s automatic dereferencing of method
receivers.
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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