pub struct ResponseBuilder { /* private fields */ }Expand description
Builds a response.
Implementations§
Source§impl ResponseBuilder
impl ResponseBuilder
Sourcepub fn new(
status: StatusCode,
reason: impl Into<Bytes>,
) -> Result<Self, BuildError>
pub fn new( status: StatusCode, reason: impl Into<Bytes>, ) -> Result<Self, BuildError>
Start a response.
The reason phrase is checked: it is the one field on a start line that carries free text, which makes it the obvious place to try to inject a line break.
Sourcepub fn to_request(
request: &Request,
status: StatusCode,
reason: impl Into<Bytes>,
) -> Result<Self, BuildError>
pub fn to_request( request: &Request, status: StatusCode, reason: impl Into<Bytes>, ) -> Result<Self, BuildError>
Start a response to a request, copying the headers RFC 3261 §8.2.6.2 requires.
Via is copied in order and in full: the response finds its way back by walking
that list, and reordering or deduplicating it strands the response. From, To,
Call-ID and CSeq are copied verbatim, which also means a request whose To was
unparseable still gets a well-formed response — the point of copying rather than
re-deriving.
Sourcepub fn header(
self,
name: HeaderName,
value: impl Into<Bytes>,
) -> Result<Self, BuildError>
pub fn header( self, name: HeaderName, value: impl Into<Bytes>, ) -> Result<Self, BuildError>
Append a header, rejecting a value that could inject a line break.
Sourcepub fn set_header(
self,
name: &HeaderName,
value: impl Into<Bytes>,
) -> Result<Self, BuildError>
pub fn set_header( self, name: &HeaderName, value: impl Into<Bytes>, ) -> Result<Self, BuildError>
Replace every header of this name with one carrying this value.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ResponseBuilder
impl RefUnwindSafe for ResponseBuilder
impl Send for ResponseBuilder
impl Sync for ResponseBuilder
impl Unpin for ResponseBuilder
impl UnsafeUnpin for ResponseBuilder
impl UnwindSafe for ResponseBuilder
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