[][src]Struct rtsp_types::Response

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

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

impl Response<Empty>[src]

pub fn builder(version: Version, status: StatusCode) -> ResponseBuilder[src]

Build a new Response for a given RTSP version and status code.

impl<Body> Response<Body>[src]

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

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.

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

Calculate the number of bytes needed to serialize the response.

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

Get the version of the response.

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

Set the version of the response.

pub fn status(&self) -> StatusCode[src]

Get the status code of the response.

pub fn set_status(&mut self, status: StatusCode)[src]

Set the status code of the response.

pub fn reason_phrase(&self) -> &str[src]

Get the reason phrase of the response.

pub fn set_reason_phrase<S: Into<String>>(&mut self, reason_phrase: S)[src]

Set the reason phrase of the response.

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

Get the body of the response.

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

Convert the response into its body.

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

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.

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

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.

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 Response<Body>[src]

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

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

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

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

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

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

Auto Trait Implementations

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

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

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

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

impl<Body> UnwindSafe for Response<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.