Struct tauri::http::ResponseBuilder
x3A;:ResponseBuilder,
pub struct ResponseBuilder { /* fields omitted */ }
Expand description
An HTTP response builder
This type can be used to construct an instance of Response
through a builder-like pattern.
#
ImplementationsBuilder#
implnew() -> Builder#
pub fnCreates a new default instance of Builder
to construct either a Head
or a Response
.
#
Exampleslet response = ResponseBuilder::new()
.status(200)
.mimetype("text/html")
.body(Vec::new())
.unwrap();
mimetype(self, mimetype: &str) -> Builder#
pub fnSet the HTTP mimetype for this response.
status<T>(self, status: T) -> Builder where StatusCode: TryFrom<T>, <StatusCode as TryFrom<T>>::Error: Into<Error>,#
pub fnSet the HTTP status for this response.
version(self, version: Version) -> Builder#
pub fnSet the HTTP version for this response.
This function will configure the HTTP version of the Response
that will be returned from Builder::build
.
By default this is HTTP/1.1
header<K, V>(self, key: K, value: V) -> Builder where HeaderName: TryFrom<K>, <HeaderName as TryFrom<K>>::Error: Into<Error>, HeaderValue: TryFrom<V>, <HeaderValue as TryFrom<V>>::Error: Into<Error>,#
pub fnAppends a header to this response builder.
This function will append the provided key/value as a header to the internal HeaderMap
being constructed. Essentially this is equivalent to calling HeaderMap::append
.
body( self, body: Vec<u8, Global> ) -> Result<Response, Box<dyn Error + 'static, Global>>#
pub fn“Consumes” this builder, using the provided body
to return a constructed Response
.
#
ErrorsThis function may return an error if any previously configured argument failed to parse or get converted to the internal representation. For example if an invalid head
was specified via header("Foo", "Bar\r\n")
the error will be returned when this function is called rather than when header
was called.
#
Exampleslet response = ResponseBuilder::new()
.mimetype("text/html")
.body(Vec::new())
.unwrap();
#
Trait ImplementationsDebug for Builder#
implfmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>#
pub fnFormats the value using the given formatter. Read more
Default for Builder#
impldefault() -> Builder#
pub fnReturns the “default value” for a type. Read more
#
Auto Trait ImplementationsRefUnwindSafe for Builder#
impl \!Send for Builder#
impl \!Sync for Builder#
impl \!Unpin for Builder#
implUnwindSafe for Builder#
impl \!#
Blanket ImplementationsAny for T where T: 'static + ?Sized,[src]#
impl<T>type_id(&self) -> TypeId[src]#
pub fnGets the TypeId
of self
. Read more
Borrow<T> for T where T: ?Sized,[src]#
impl<T>borrow(&self) -> &T[src]#
pub fnImmutably borrows from an owned value. Read more
BorrowMut<T> for T where T: ?Sized,[src]#
impl<T>borrow_mut(&mut self) -> &mutT[src]#
pub fnMutably borrows from an owned value. Read more
From<T> for T[src]#
impl<T>from(t: T) -> T[src]#
pub fnPerforms the conversion.
Into<U> for T where U: From<T>,[src]#
impl<T, U>into(self) -> U[src]#
pub fnPerforms the conversion.
TryFrom<U> for T where U: Into<T>,[src]#
impl<T, U>Error = Infallible#
typeThe type returned in the event of a conversion error.
try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]#
pub fnPerforms the conversion.
TryInto<U> for T where U: TryFrom<T>,[src]#
impl<T, U>Error = <U as TryFrom<T>>::Error#
typeThe type returned in the event of a conversion error.
try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]#
pub fnPerforms the conversion.