Struct rtsp_types::Response
source · pub struct Response<Body> { /* private fields */ }Expand description
RTSP Response.
Represents an RTSP response and providers functions to construct, modify and read responses.
See RFC 7826 section 8 for the details about methods.
§Creating an OK response
let response = rtsp_types::Response::builder(
rtsp_types::Version::V2_0,
rtsp_types::StatusCode::Ok,
)
.header(rtsp_types::headers::CSEQ, "1")
.empty();Implementations§
source§impl Response<Empty>
impl Response<Empty>
sourcepub fn builder(version: Version, status: StatusCode) -> ResponseBuilder
pub fn builder(version: Version, status: StatusCode) -> ResponseBuilder
Build a new Response for a given RTSP version and status code.
source§impl<Body> Response<Body>
impl<Body> Response<Body>
sourcepub fn write<'b, W: Write + 'b>(&self, w: &'b mut W) -> Result<(), WriteError>
pub fn write<'b, W: Write + 'b>(&self, w: &'b mut W) -> Result<(), WriteError>
Serialize the response to any std::io::Write.
Resuming writing after std::io::ErrorKind::WouldBlock is not supported. Any previously
written data will have to be discarded for resuming.
sourcepub fn set_version(&mut self, version: Version)
pub fn set_version(&mut self, version: Version)
Set the version of the response.
sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Get the status code of the response.
sourcepub fn set_status(&mut self, status: StatusCode)
pub fn set_status(&mut self, status: StatusCode)
Set the status code of the response.
sourcepub fn reason_phrase(&self) -> &str
pub fn reason_phrase(&self) -> &str
Get the reason phrase of the response.
sourcepub fn set_reason_phrase<S: Into<String>>(&mut self, reason_phrase: S)
pub fn set_reason_phrase<S: Into<String>>(&mut self, reason_phrase: S)
Set the reason phrase of the response.
sourcepub fn map_body<NewBody: AsRef<[u8]>, F: FnOnce(Body) -> NewBody>(
self,
func: F,
) -> Response<NewBody>
pub fn map_body<NewBody: AsRef<[u8]>, F: FnOnce(Body) -> NewBody>( self, func: F, ) -> Response<NewBody>
Modify the body of the response with a closure.
This replaces the Content-Length header of the message with the length of the new body.
sourcepub fn replace_body<NewBody: AsRef<[u8]>>(
self,
new_body: NewBody,
) -> Response<NewBody>
pub fn replace_body<NewBody: AsRef<[u8]>>( self, new_body: NewBody, ) -> Response<NewBody>
Replace the body of the response with a different body.
This replaces the Content-Length header of the message with the length of the new body.
sourcepub fn append_header<V: Into<HeaderValue>>(
&mut self,
name: HeaderName,
value: V,
)
pub fn append_header<V: Into<HeaderValue>>( &mut self, name: HeaderName, value: V, )
Appends a value to an existing RTSP header or inserts it.
Additional values are comma separated as defined in RFC 7826 section 5.2.
sourcepub fn insert_header<V: Into<HeaderValue>>(
&mut self,
name: HeaderName,
value: V,
)
pub fn insert_header<V: Into<HeaderValue>>( &mut self, name: HeaderName, value: V, )
Insert an RTSP header with its value.
If a header with the same name already exists then its value will be replaced.
See append for appending additional values to a header.
sourcepub fn append_typed_header<H: TypedAppendableHeader>(&mut self, header: &H)
pub fn append_typed_header<H: TypedAppendableHeader>(&mut self, header: &H)
Append a typed RTSP header with its value.
sourcepub fn insert_typed_header<H: TypedHeader>(&mut self, header: &H)
pub fn insert_typed_header<H: TypedHeader>(&mut self, header: &H)
Insert a typed RTSP header with its value.
If a header with the same name already exists then its value will be replaced.
sourcepub fn remove_header(&mut self, name: &HeaderName)
pub fn remove_header(&mut self, name: &HeaderName)
Removes and RTSP header if it exists.
sourcepub fn header(&self, name: &HeaderName) -> Option<&HeaderValue>
pub fn header(&self, name: &HeaderName) -> Option<&HeaderValue>
Gets an RTSP header value if it exists.
sourcepub fn typed_header<H: TypedHeader>(
&self,
) -> Result<Option<H>, HeaderParseError>
pub fn typed_header<H: TypedHeader>( &self, ) -> Result<Option<H>, HeaderParseError>
Gets a typed RTSP header value if it exists.
sourcepub fn header_mut(&mut self, name: &HeaderName) -> Option<&mut HeaderValue>
pub fn header_mut(&mut self, name: &HeaderName) -> Option<&mut HeaderValue>
Gets a mutable reference to an RTSP header value if it exists.
sourcepub fn headers(&self) -> impl Iterator<Item = (&HeaderName, &HeaderValue)>
pub fn headers(&self) -> impl Iterator<Item = (&HeaderName, &HeaderValue)>
Iterator over all header name and value pairs.
sourcepub fn header_names(&self) -> impl Iterator<Item = &HeaderName>
pub fn header_names(&self) -> impl Iterator<Item = &HeaderName>
Iterator over all header names.
sourcepub fn header_values(&self) -> impl Iterator<Item = &HeaderValue>
pub fn header_values(&self) -> impl Iterator<Item = &HeaderValue>
Iterator over all header values.