pub struct MockUrl {
pub url_representation: String,
pub slashable: bool,
pub base_url_representation: Option<String>,
pub query: Option<UrlQuery>,
pub fragment: Option<String>,
pub format: Option<String>,
pub content: Option<ReadableBuffer>,
/* private fields */
}Expand description
A standalone URL implementation intended for testing purposes.
You can set a URL representation as you please, mocking any other scheme or not following the URL notation at all. Thus mock URLs must be explictly created via UrlContext::mock_url and cannot be returned by general UrlContext functions.
The URL::base and URL::relative functions are supported in two modes. When slashable is true, they will interpret the URL representation as a Unix-style filesystem path, whereby the path separator is “/”, and “.” and “..” are supported for path traversal. When slashable is false, URL::relative does simple string concatenation, and you must explicitly provide a base_url_representation if you want to support URL::base. For both functions, the content and format are simply cloned.
URL::conform does nothing.
For custom URLs that are supported by general UrlContext functions, see InternalUrl.
Fields§
§url_representation: StringThe URL representation.
slashable: boolWhether the URL representation is “slashable”.
base_url_representation: Option<String>The optional base URL representation (used when slashable is false).
query: Option<UrlQuery>The optional query.
fragment: Option<String>The optional fragment.
format: Option<String>The optional format.
content: Option<ReadableBuffer>The optional content.
Implementations§
Trait Implementations§
Source§impl URL for MockUrl
impl URL for MockUrl
Source§fn context(&self) -> &UrlContext
fn context(&self) -> &UrlContext
Source§fn format(&self) -> Option<String>
fn format(&self) -> Option<String>
Source§fn base(&self) -> Option<UrlRef>
fn base(&self) -> Option<UrlRef>
Source§fn conform(&mut self) -> Result<(), UrlError>
fn conform(&mut self) -> Result<(), UrlError>
blocking only.Source§fn conform_async(&self) -> Result<ConformFuture, UrlError>
fn conform_async(&self) -> Result<ConformFuture, UrlError>
async only.Source§fn open_async(&self) -> Result<OpenFuture, UrlError>
fn open_async(&self) -> Result<OpenFuture, UrlError>
async only.Auto Trait Implementations§
impl Freeze for MockUrl
impl !RefUnwindSafe for MockUrl
impl Send for MockUrl
impl Sync for MockUrl
impl Unpin for MockUrl
impl !UnwindSafe for MockUrl
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.