pub struct DirectResponse { /* private fields */ }Expand description
What a surface answered, stated without a transport.
Implementations§
Source§impl DirectResponse
impl DirectResponse
Sourcepub fn new(status: HttpStatus) -> DirectResponse
pub fn new(status: HttpStatus) -> DirectResponse
Answers with a status and nothing else.
Sourcepub fn content(
status: HttpStatus,
content_type: &str,
body: impl Into<Vec<u8>>,
) -> DirectResponse
pub fn content( status: HttpStatus, content_type: &str, body: impl Into<Vec<u8>>, ) -> DirectResponse
Answers with a status, a content type, and a body.
Sourcepub fn with_header(self, name: &str, value: &str) -> DirectResponse
pub fn with_header(self, name: &str, value: &str) -> DirectResponse
States one header on this answer.
Sourcepub fn with_body(self, body: impl Into<Vec<u8>>) -> DirectResponse
pub fn with_body(self, body: impl Into<Vec<u8>>) -> DirectResponse
States the body of this answer.
Sourcepub fn with_chunks(
self,
chunks: Pin<Box<dyn Stream<Item = Result<Vec<u8>, Error>> + Send>>,
) -> DirectResponse
pub fn with_chunks( self, chunks: Pin<Box<dyn Stream<Item = Result<Vec<u8>, Error>> + Send>>, ) -> DirectResponse
States a body this answer produces over time.
Sourcepub fn into_body(self) -> DirectBody
pub fn into_body(self) -> DirectBody
Returns what this answer carries, which is either bytes or what produces them.
Sourcepub async fn collected(self) -> DirectResponse
pub async fn collected(self) -> DirectResponse
Answers the same thing with every chunk of its body taken.
A body already in hand is already collected. One produced over time is read to its end, which is what anything reading an answer whole has to do.
Sourcepub fn with_status(self, status: HttpStatus) -> DirectResponse
pub fn with_status(self, status: HttpStatus) -> DirectResponse
Answers the same thing under a different status.
Sourcepub fn status(&self) -> HttpStatus
pub fn status(&self) -> HttpStatus
Returns the status this answer carries.
Sourcepub fn header(&self, name: &str) -> Option<&str>
pub fn header(&self, name: &str) -> Option<&str>
Returns the value of one header, matched without regard to case.
Sourcepub fn headers(&self) -> impl Iterator<Item = (&str, &str)>
pub fn headers(&self) -> impl Iterator<Item = (&str, &str)>
Returns every header this answer carries, in the order it states them.
Trait Implementations§
Source§impl Debug for DirectResponse
impl Debug for DirectResponse
Source§impl From<DirectError> for DirectResponse
impl From<DirectError> for DirectResponse
Source§fn from(error: DirectError) -> DirectResponse
fn from(error: DirectError) -> DirectResponse
Auto Trait Implementations§
impl !RefUnwindSafe for DirectResponse
impl !Sync for DirectResponse
impl !UnwindSafe for DirectResponse
impl Freeze for DirectResponse
impl Send for DirectResponse
impl Unpin for DirectResponse
impl UnsafeUnpin for DirectResponse
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<This> HttpProgramExt<This> for This
impl<This> HttpProgramExt<This> for This
Source§fn compile_http<Program>(
&self,
program: Program,
) -> <Program as HttpProgramAlg<This>>::Routewhere
Program: HttpProgramAlg<This>,
fn compile_http<Program>(
&self,
program: Program,
) -> <Program as HttpProgramAlg<This>>::Routewhere
Program: HttpProgramAlg<This>,
Compiles a named HTTP program with this interpreter.