pub struct Request<Body> { /* private fields */ }
Expand description
RTSP Request.
Represents an RTSP request and providers functions to construct, modify and read requests.
See RFC 7826 section 7 for the details about methods.
§Creating an OPTIONS
request
let request = rtsp_types::Request::builder(
rtsp_types::Method::Options,
rtsp_types::Version::V2_0
)
.header(rtsp_types::headers::CSEQ, "1")
.empty();
This request contains an empty body.
§Creating a SET_PARAMETER
request with a request body
let request = rtsp_types::Request::builder(
rtsp_types::Method::SetParameter,
rtsp_types::Version::V2_0
)
.request_uri(rtsp_types::Url::parse("rtsp://example.com/test").expect("Invalid URI"))
.header(rtsp_types::headers::CSEQ, "2")
.header(rtsp_types::headers::CONTENT_TYPE, "text/parameters")
.build(Vec::from(&b"barparam: barstuff"[..]));
Implementations§
Source§impl Request<Empty>
impl Request<Empty>
Sourcepub fn builder(method: Method, version: Version) -> RequestBuilder
pub fn builder(method: Method, version: Version) -> RequestBuilder
Build a new Request
for a given method and RTSP version.
Source§impl<Body> Request<Body>
impl<Body> Request<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 request 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_method(&mut self, method: Method)
pub fn set_method(&mut self, method: Method)
Set the method of the request.
Sourcepub fn request_uri(&self) -> Option<&Url>
pub fn request_uri(&self) -> Option<&Url>
Get the request URI of the request.
Sourcepub fn set_request_uri(&mut self, request_uri: Option<Url>)
pub fn set_request_uri(&mut self, request_uri: Option<Url>)
Set the request URI of the request.
Sourcepub fn set_version(&mut self, version: Version)
pub fn set_version(&mut self, version: Version)
Set the version of the request.
Sourcepub fn map_body<NewBody: AsRef<[u8]>, F: FnOnce(Body) -> NewBody>(
self,
func: F,
) -> Request<NewBody>
pub fn map_body<NewBody: AsRef<[u8]>, F: FnOnce(Body) -> NewBody>( self, func: F, ) -> Request<NewBody>
Modify the body of the request 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,
) -> Request<NewBody>
pub fn replace_body<NewBody: AsRef<[u8]>>( self, new_body: NewBody, ) -> Request<NewBody>
Replace the body of the request 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.