pub enum UrlMatcher {
Substring(String),
Regex(Regex),
}Available on crate feature
expect only.Expand description
URL match predicate used by request/response expectations.
From<&str> / From<String> build a UrlMatcher::Substring, while
From<regex::Regex> builds a UrlMatcher::Regex — so callers can pass
any of the three to crate::Tab::expect_request /
crate::Tab::expect_response.
§Examples
use zendriver::UrlMatcher;
let m: UrlMatcher = "/api/".into();
assert!(m.matches("https://example.com/api/users"));
assert!(!m.matches("https://example.com/static/app.js"));Variants§
Substring(String)
Matches if the URL contains the needle anywhere.
Regex(Regex)
Matches via regex::Regex::is_match.
Implementations§
Source§impl UrlMatcher
impl UrlMatcher
Sourcepub fn matches(&self, url: &str) -> bool
pub fn matches(&self, url: &str) -> bool
Returns true if url matches this matcher.
§Examples
use zendriver::UrlMatcher;
let re = regex::Regex::new(r"^https://example\.com/api/").unwrap();
let m: UrlMatcher = re.into();
assert!(m.matches("https://example.com/api/v1/users"));
assert!(!m.matches("https://example.com/static/app.js"));Trait Implementations§
Source§impl Clone for UrlMatcher
impl Clone for UrlMatcher
Source§fn clone(&self) -> UrlMatcher
fn clone(&self) -> UrlMatcher
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 UrlMatcher
impl Debug for UrlMatcher
Source§impl From<&str> for UrlMatcher
impl From<&str> for UrlMatcher
Source§impl From<Regex> for UrlMatcher
impl From<Regex> for UrlMatcher
Auto Trait Implementations§
impl Freeze for UrlMatcher
impl RefUnwindSafe for UrlMatcher
impl Send for UrlMatcher
impl Sync for UrlMatcher
impl Unpin for UrlMatcher
impl UnsafeUnpin for UrlMatcher
impl UnwindSafe for UrlMatcher
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