pub struct UniversalResponse {
pub status_code: u16,
pub headers: HashMap<Cow<'static, str>, Cow<'static, str>>,
pub body: ResponseBody,
pub content_type: Cow<'static, str>,
}Expand description
Universal response type for framework integration
Fields§
§status_code: u16§headers: HashMap<Cow<'static, str>, Cow<'static, str>>§body: ResponseBody§content_type: Cow<'static, str>Implementations§
Source§impl UniversalResponse
impl UniversalResponse
Sourcepub fn json_pooled(data: JsonData) -> Self
pub fn json_pooled(data: JsonData) -> Self
Create a JSON response using pooled HashMap (more efficient)
Sourcepub fn stream(frames: Vec<StreamFrame>) -> Self
pub fn stream(frames: Vec<StreamFrame>) -> Self
Create a streaming response
Sourcepub fn server_sent_events(events: Vec<String>) -> Self
pub fn server_sent_events(events: Vec<String>) -> Self
Create a Server-Sent Events response
Sourcepub fn with_header(
self,
name: impl Into<Cow<'static, str>>,
value: impl Into<Cow<'static, str>>,
) -> Self
pub fn with_header( self, name: impl Into<Cow<'static, str>>, value: impl Into<Cow<'static, str>>, ) -> Self
Add a header to the response
Sourcepub fn with_status(self, status: u16) -> Self
pub fn with_status(self, status: u16) -> Self
Set the status code
Trait Implementations§
Source§impl Clone for UniversalResponse
impl Clone for UniversalResponse
Source§fn clone(&self) -> UniversalResponse
fn clone(&self) -> UniversalResponse
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for UniversalResponse
impl RefUnwindSafe for UniversalResponse
impl Send for UniversalResponse
impl Sync for UniversalResponse
impl Unpin for UniversalResponse
impl UnwindSafe for UniversalResponse
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more