pub struct Session {Show 13 fields
pub origin: Origin,
pub session_name: String,
pub session_description: Option<String>,
pub uri: Option<String>,
pub emails: Vec<String>,
pub phones: Vec<String>,
pub connection: Option<Connection>,
pub bandwidths: Vec<Bandwidth>,
pub times: Vec<Time>,
pub time_zones: Vec<TimeZone>,
pub key: Option<Key>,
pub attributes: Vec<Attribute>,
pub medias: Vec<Media>,
}Expand description
SDP session description.
See RFC 8866 Section 5 for more details.
Fields§
§origin: OriginOriginator of the session.
session_name: StringName of the session.
session_description: Option<String>Session description.
uri: Option<String>URI to additional information about the session.
emails: Vec<String>E-Mail contacts for the session.
phones: Vec<String>Phone contacts for the session.
connection: Option<Connection>Connection data for the session.
bandwidths: Vec<Bandwidth>Bandwidth information for the session.
times: Vec<Time>Timing information for the session.
time_zones: Vec<TimeZone>Time zone information for the session.
key: Option<Key>Encryption key for the session.
attributes: Vec<Attribute>Attributes of the session.
medias: Vec<Media>Media descriptions for this session.
Implementations§
Source§impl Session
impl Session
Sourcepub fn parse(data: &[u8]) -> Result<Session, ParserError>
pub fn parse(data: &[u8]) -> Result<Session, ParserError>
Parse an SDP session description from a byte slice.
Examples found in repository?
4fn main() -> process::ExitCode {
5 let mut args = env::args();
6 let _ = args.next().unwrap();
7 let Some(file) = args.next() else {
8 eprintln!("Usage: parse [file.sdp]");
9 return process::ExitCode::FAILURE;
10 };
11
12 let mut file = match fs::File::open(file) {
13 Ok(file) => file,
14 Err(err) => {
15 eprintln!("Failed to open file: {err}");
16 return process::ExitCode::FAILURE;
17 }
18 };
19
20 let mut content = Vec::new();
21 match file.read_to_end(&mut content) {
22 Ok(_) => {}
23 Err(err) => {
24 eprintln!("Failed to read file: {err}");
25 return process::ExitCode::FAILURE;
26 }
27 };
28
29 let sdp = match sdp_types::Session::parse(&content) {
30 Ok(sdp) => sdp,
31 Err(err) => {
32 eprintln!("Failed to parse SDP: {err}");
33 return process::ExitCode::FAILURE;
34 }
35 };
36
37 println!("{sdp:#?}");
38
39 process::ExitCode::SUCCESS
40}Source§impl Session
impl Session
pub fn new(origin: Origin, session_name: impl ToString) -> Self
pub fn builder(origin: Origin, session_name: impl ToString) -> Session
pub fn set_session_description(&mut self, session_description: impl ToString)
pub fn set_uri(&mut self, uri: impl ToString)
pub fn add_email(&mut self, email: impl ToString)
pub fn add_emails(&mut self, emails: impl IntoIterator<Item = impl ToString>)
pub fn add_phone(&mut self, phone: impl ToString)
pub fn add_phones(&mut self, phones: impl IntoIterator<Item = impl ToString>)
pub fn set_connection(&mut self, connection: impl Into<Connection>)
pub fn add_bandwidth(&mut self, bandwidth: Bandwidth)
pub fn add_bandwidths( &mut self, bandwidths: impl IntoIterator<Item = Bandwidth>, )
pub fn add_time(&mut self, time: Time)
pub fn add_times(&mut self, times: impl IntoIterator<Item = Time>)
pub fn add_time_zone(&mut self, time_zone: TimeZone)
pub fn add_time_zones(&mut self, time_zones: impl IntoIterator<Item = TimeZone>)
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>, )
pub fn add_media(&mut self, media: Media)
pub fn add_medias(&mut self, medias: impl IntoIterator<Item = Media>)
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 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