Struct Request

Source
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>

Source

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

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

Source§

impl<Body> Request<Body>

Source

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

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.

Source

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

Calculate the number of bytes needed to serialize the request.

Source

pub fn method(&self) -> &Method

Get the method of the request.

Source

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

Set the method of the request.

Source

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

Get the request URI of the request.

Source

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

Set the request URI of the request.

Source

pub fn version(&self) -> Version

Get the version of the request.

Source

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

Set the version of the request.

Source

pub fn body(&self) -> &Body

Get the body of the request.

Source

pub fn into_body(self) -> Body

Convert the request into its body.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn append_typed_header<H: TypedAppendableHeader>(&mut self, header: &H)

Append a typed RTSP header with its value.

Source

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.

Source

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

Removes and RTSP header if it exists.

Source

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

Gets an RTSP header value if it exists.

Source

pub fn typed_header<H: TypedHeader>( &self, ) -> Result<Option<H>, HeaderParseError>

Gets a typed RTSP header value if it exists.

Source

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

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

Source

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

Iterator over all header name and value pairs.

Source

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

Iterator over all header names.

Source

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

Iterator over all header values.

Trait Implementations§

Source§

impl<Body> AsMut<Headers> for Request<Body>

Source§

fn as_mut(&mut self) -> &mut Headers

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<Body> AsRef<Headers> for Request<Body>

Source§

fn as_ref(&self) -> &Headers

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<Body: Clone> Clone for Request<Body>

Source§

fn clone(&self) -> Request<Body>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Body: Debug> Debug for Request<Body>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Body> From<Request<Body>> for Message<Body>

Source§

fn from(v: Request<Body>) -> Self

Converts to this type from the input type.
Source§

impl<BodyA, BodyB: PartialEq<BodyA>> PartialEq<Request<BodyA>> for Request<BodyB>

Source§

fn eq(&self, other: &Request<BodyA>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Body: Eq> Eq for Request<Body>

Auto Trait Implementations§

§

impl<Body> Freeze for Request<Body>
where Body: Freeze,

§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,