pub struct Response<'a> { /* private fields */ }Expand description
HTTP response writer passed to a route handler.
Borrows the underlying C response for the duration of the handler call. Do not store this value beyond the handler invocation.
Implementations§
Source§impl<'a> Response<'a>
impl<'a> Response<'a>
Sourcepub unsafe fn from_raw(raw: *mut ove_httpd_resp_t) -> Self
pub unsafe fn from_raw(raw: *mut ove_httpd_resp_t) -> Self
Create a Response from a raw C pointer.
§Safety
raw must be a valid pointer obtained from an active httpd handler
callback and must remain valid for the lifetime 'a.
Sourcepub fn json(&self, status: i32, json: &[u8]) -> Result<()>
pub fn json(&self, status: i32, json: &[u8]) -> Result<()>
Send a JSON response.
json must be a null-terminated byte string.
§Errors
Returns an error if the response cannot be sent.
Sourcepub fn send(&self, status: i32, content_type: &[u8], body: &[u8]) -> Result<()>
pub fn send(&self, status: i32, content_type: &[u8], body: &[u8]) -> Result<()>
Send a response with arbitrary content type.
content_type must be a null-terminated byte string.
§Errors
Returns an error if the response cannot be sent.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Response<'a>
impl<'a> RefUnwindSafe for Response<'a>
impl<'a> !Send for Response<'a>
impl<'a> !Sync for Response<'a>
impl<'a> Unpin for Response<'a>
impl<'a> UnwindSafe for Response<'a>
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