pub struct Media {
pub media: String,
pub port: u16,
pub num_ports: Option<u16>,
pub proto: String,
pub fmt: String,
pub media_title: Option<String>,
pub connections: Vec<Connection>,
pub bandwidths: Vec<Bandwidth>,
pub key: Option<Key>,
pub attributes: Vec<Attribute>,
}Expand description
Media description.
See RFC 8866 Section 5.14 for more details.
Fields§
§media: StringMedia type, e.g. “audio”, “video”, “text”, “application” or “message”.
port: u16Transport port to which the media is sent.
num_ports: Option<u16>Number of ports starting at port used for the media.
proto: StringTransport protocol.
fmt: StringMedia format description.
media_title: Option<String>Media title.
connections: Vec<Connection>Connection data for the media.
bandwidths: Vec<Bandwidth>Bandwidth information for the media.
key: Option<Key>Encryption key for the media.
attributes: Vec<Attribute>Attributes of the media.
Implementations§
Source§impl Media
impl Media
pub fn new( media: MediaType, port: u16, proto: TransportProto, fmt: impl ToString, ) -> Self
pub fn builder( media: MediaType, port: u16, proto: TransportProto, fmt: impl ToString, ) -> Media
pub fn set_num_ports(&mut self, num_ports: u16)
pub fn set_media_title(&mut self, media_title: impl ToString)
pub fn add_connection(&mut self, connection: impl Into<Connection>)
pub fn add_connections( &mut self, connections: impl IntoIterator<Item = impl Into<Connection>>, )
pub fn add_bandwidth(&mut self, bandwidth: Bandwidth)
pub fn add_bandwidths( &mut self, bandwidths: impl IntoIterator<Item = Bandwidth>, )
pub fn set_encryption_key(&mut self, key: impl Into<Key>)
pub fn add_attribute(&mut self, attribute: impl Into<Attribute>)
pub fn add_attribute_from_str(&mut self, attribute: impl ToString)
pub fn add_attribute_with_value( &mut self, attribute: impl ToString, value: impl ToString, )
pub fn add_attributes( &mut self, attributes: impl IntoIterator<Item = impl Into<Attribute>>, )
pub fn add_attributes_from_strs( &mut self, attributes: impl IntoIterator<Item = impl ToString>, )
Sourcepub fn has_attribute(&self, name: &str) -> bool
pub fn has_attribute(&self, name: &str) -> bool
Checks if the given attribute exists.
Sourcepub fn get_first_attribute_value<'a>(
&'a self,
name: &'a str,
) -> Option<Option<&'a str>>
pub fn get_first_attribute_value<'a>( &'a self, name: &'a str, ) -> Option<Option<&'a str>>
Gets the first value of the given attribute.
The outter Option reflects the availability of the attribute.
The inner Option reflects the optional value of the attribute.
Sourcepub fn get_attribute_values<'a>(
&'a self,
name: &'a str,
) -> impl Iterator<Item = Option<&'a str>>
pub fn get_attribute_values<'a>( &'a self, name: &'a str, ) -> impl Iterator<Item = Option<&'a str>>
Gets an iterator over all attribute values of the given name.
Sourcepub fn try_parse_mediatype(&self) -> Result<MediaType, ParseEnumError>
pub fn try_parse_mediatype(&self) -> Result<MediaType, ParseEnumError>
Tries to parse the media String of self as MediaType
Sourcepub fn set_mediatype(&mut self, media: MediaType)
pub fn set_mediatype(&mut self, media: MediaType)
Sets the media String of self from the specified MediaType
Sourcepub fn parse_transport_proto(&self) -> TransportProto
pub fn parse_transport_proto(&self) -> TransportProto
Parses the proto String of self as TransportProto
Sourcepub fn set_transport_proto(&mut self, proto: TransportProto)
pub fn set_transport_proto(&mut self, proto: TransportProto)
Sets the proto String of self from the specified TransportProto
Sourcepub fn get_first_attribute_typed<T: TypedAttribute>(
&self,
) -> Option<Result<T, AttributeError>>
pub fn get_first_attribute_typed<T: TypedAttribute>( &self, ) -> Option<Result<T, AttributeError>>
Gets the first value of the given typed attribute.
Sourcepub fn attributes_typed<'a, T: TypedAttribute>(
&'a self,
) -> impl Iterator<Item = Result<T, AttributeError>> + 'a
pub fn attributes_typed<'a, T: TypedAttribute>( &'a self, ) -> impl Iterator<Item = Result<T, AttributeError>> + 'a
Gets an iterator over all attribute values of the given name.
Each item represents the attribute parsing Result.
The iterator does not terminate upon an error item; continues with the next attribute