[][src]Struct rtsp_types::Request

pub struct Request<Body> { /* fields omitted */ }

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

impl Request<Empty>[src]

pub fn builder(method: Method, version: Version) -> RequestBuilder[src]

Build a new Request for a given method and RTSP version.

impl<Body> Request<Body>[src]

pub fn write<'b, W: Write + 'b>(&self, w: &'b mut W) -> Result<(), WriteError> where
    Body: AsRef<[u8]>, 
[src]

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.

pub fn write_len(&self) -> u64 where
    Body: AsRef<[u8]>, 
[src]

Calculate the number of bytes needed to serialize the request.

pub fn method(&self) -> &Method[src]

Get the method of the request.

pub fn set_method(&mut self, method: Method)[src]

Set the method of the request.

pub fn request_uri(&self) -> Option<&Url>[src]

Get the request URI of the request.

pub fn set_request_uri(&mut self, request_uri: Option<Url>)[src]

Set the request URI of the request.

pub fn version(&self) -> Version[src]

Get the version of the request.

pub fn set_version(&mut self, version: Version)[src]

Set the version of the request.

pub fn body(&self) -> &Body[src]

Get the body of the request.

pub fn into_body(self) -> Body[src]

Convert the request into its body.

pub fn map_body<NewBody: AsRef<[u8]>, F: FnOnce(Body) -> NewBody>(
    self,
    func: F
) -> Request<NewBody>
[src]

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.

pub fn replace_body<NewBody: AsRef<[u8]>>(
    self,
    new_body: NewBody
) -> Request<NewBody>
[src]

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.

pub fn append_header<V: Into<HeaderValue>>(
    &mut self,
    name: HeaderName,
    value: V
)
[src]

Appends a value to an existing RTSP header or inserts it.

Additional values are comma separated as defined in RFC 7826 section 5.2.

pub fn insert_header<V: Into<HeaderValue>>(
    &mut self,
    name: HeaderName,
    value: V
)
[src]

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.

pub fn remove_header(&mut self, name: &HeaderName)[src]

Removes and RTSP header if it exists.

pub fn header(&self, name: &HeaderName) -> Option<&HeaderValue>[src]

Gets an RTSP header value if it exists.

pub fn header_mut(&mut self, name: &HeaderName) -> Option<&mut HeaderValue>[src]

Gets a mutable reference to an RTSP header value if it exists.

pub fn headers(&self) -> impl Iterator<Item = (&HeaderName, &HeaderValue)>[src]

Iterator over all header name and value pairs.

pub fn header_names(&self) -> impl Iterator<Item = &HeaderName>[src]

Iterator over all header names.

pub fn header_values(&self) -> impl Iterator<Item = &HeaderValue>[src]

Iterator over all header values.

Trait Implementations

impl<Body> AsMut<Headers> for Request<Body>[src]

impl<Body> AsRef<Headers> for Request<Body>[src]

impl<Body: Clone> Clone for Request<Body>[src]

impl<Body: Debug> Debug for Request<Body>[src]

impl<Body: Eq> Eq for Request<Body>[src]

impl<BodyA, BodyB: PartialEq<BodyA>> PartialEq<Request<BodyA>> for Request<BodyB>[src]

impl<Body> StructuralEq for Request<Body>[src]

Auto Trait Implementations

impl<Body> RefUnwindSafe for Request<Body> where
    Body: RefUnwindSafe

impl<Body> Send for Request<Body> where
    Body: Send

impl<Body> Sync for Request<Body> where
    Body: Sync

impl<Body> Unpin for Request<Body> where
    Body: Unpin

impl<Body> UnwindSafe for Request<Body> where
    Body: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.