pub struct WebResourceResponse { /* private fields */ }Expand description
The response returned from a WebView::on_web_resource_requested handler
to fulfill a request from memory. Defaults to 200 OK with no headers; add a
content_type so the page interprets the body
correctly.
Implementations§
Source§impl WebResourceResponse
impl WebResourceResponse
Sourcepub fn new(body: impl Into<Vec<u8>>) -> Self
pub fn new(body: impl Into<Vec<u8>>) -> Self
Creates a 200 OK response with the given body bytes.
Sourcepub fn status(self, code: u16, reason: &str) -> Self
pub fn status(self, code: u16, reason: &str) -> Self
Sets the HTTP status code and reason phrase, for example 404 and
Not Found.
Sourcepub fn content_type(self, value: &str) -> Self
pub fn content_type(self, value: &str) -> Self
Sets the Content-Type header, for example text/html.
Auto Trait Implementations§
impl Freeze for WebResourceResponse
impl RefUnwindSafe for WebResourceResponse
impl Send for WebResourceResponse
impl Sync for WebResourceResponse
impl Unpin for WebResourceResponse
impl UnsafeUnpin for WebResourceResponse
impl UnwindSafe for WebResourceResponse
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