Struct rtsp_types::Data

source ·
pub struct Data<Body> { /* private fields */ }
Expand description

RTSP data message.

See RFC 7826 section 14 for details about the data message.

Implementations§

source§

impl<Body> Data<Body>

source

pub fn new(channel_id: u8, body: Body) -> Self

Create a new data message for a given channel id and body.

source

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

Serialize the data 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 data.

source

pub fn channel_id(&self) -> u8

Get the channel id of the data message.

source

pub fn set_channel_id(&mut self, channel_id: u8)

Set the channel id of the data message.

source

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

Get the length of the data message.

source

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

Check if the body of the data message is empty.

source

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

Get a &[u8] slice for the body of the data message.

source

pub fn into_body(self) -> Body

Convert the data message into its body.

source

pub fn map_body<NewBody, F: FnOnce(Body) -> NewBody>( self, func: F, ) -> Data<NewBody>

Modify the body of the data message with a closure.

source

pub fn replace_body<NewBody>(self, new_body: NewBody) -> Data<NewBody>

Replace the body of the data message with a different body.

source§

impl Data<Vec<u8>>

source

pub fn from_vec(channel_id: u8, body: Vec<u8>) -> Self

Create a new data message from a Vec<u8>.

Trait Implementations§

source§

impl<Body: AsRef<[u8]>> AsRef<[u8]> for Data<Body>

source§

fn as_ref(&self) -> &[u8]

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

impl<Body: Clone> Clone for Data<Body>

source§

fn clone(&self) -> Data<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 Data<Body>

source§

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

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

impl<Body> From<Data<Body>> for Message<Body>

source§

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

Converts to this type from the input type.
source§

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

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Body: Eq> Eq for Data<Body>

Auto Trait Implementations§

§

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

§

impl<Body> RefUnwindSafe for Data<Body>
where Body: RefUnwindSafe,

§

impl<Body> Send for Data<Body>
where Body: Send,

§

impl<Body> Sync for Data<Body>
where Body: Sync,

§

impl<Body> Unpin for Data<Body>
where Body: Unpin,

§

impl<Body> UnwindSafe for Data<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> 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,

§

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

§

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

§

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,

source§

impl<T> MaybeSendSync for T