Skip to main content

ParseOptions

Struct ParseOptions 

Source
pub struct ParseOptions {
    pub blank_lines: bool,
    pub unordered_media_lines: bool,
    pub loose_fields: bool,
}
Expand description

What SessionDescription::unmarshal_with_options accepts beyond the RFC 8866 grammar.

SessionDescription::unmarshal parses with ParseOptions::strict: RFC 9429 section 5.8 has a description that is not well formed rejected, so the engine’s own parsing is the grammar and nothing else. An application that has to read what other software calls SDP can ask for each leniency by name, or for all of them with ParseOptions::lenient.

§What is accepted in every mode

These are the places where the parser is deliberately wider than the grammar, each for a reason:

  • A line may end in a bare LF instead of CRLF. RFC 8866 section 5: “parsers SHOULD be tolerant and also accept lines terminated with a single newline character”.
  • The last line may have no line ending, and empty lines may follow it. Descriptions that went through a text field or a trim() look like this.
  • z= may follow a t= line that has no r= line. RFC 4566 allowed it, and RFC 8866 moved z= into the repeat description; a description written to RFC 4566 still parses.
  • k= lines are checked for syntax and dropped (RFC 8866 section 5.12: “MUST be discarded if received”).
  • a=name: with an empty value is kept as an attribute whose value is the empty string. RFC 3611 defines one (a=rtcp-xr:), although the RFC 8866 byte-string is never empty.
  • An attribute this crate does not know is kept as it is, at either level (RFC 8866 section 5.13: “an attribute that is not understood MUST be ignored”). The typed accessors are where the value of a known attribute is checked.
  • Several c= lines in one media description are accepted; the last one is kept.

§What is always refused

A type letter RFC 8866 does not define (section 5: such a description is ignored or rejected whole), a line that is not <type>=<value>, NUL, a bare CR, text that is not UTF-8 when the description names no other set with a=charset (unmarshal, from bytes), session-level lines out of order, and a description without v=, o=, s= or t=.

Fields§

§blank_lines: bool

Skip empty lines before and between lines, as some media players accept.

§unordered_media_lines: bool

Accept i=, c=, b= and k= after a= lines inside a media description. Some gateways write them so; RFC 8866 section 5 has them “in exactly the order given”.

§loose_fields: bool

Do not check what the fields of a line contain beyond what the parser needs: fields may be separated and surrounded by any run of spaces and tabs; t= times may be any number; addresses in o= and c= need only be free of white space (and c= may lack one); i=, e= and p= text is kept unchecked; s= may be empty; extra fields after the stop time of t= are ignored.

Implementations§

Source§

impl ParseOptions

Source

pub const fn strict() -> Self

The RFC 8866 grammar, with only the tolerance every mode has. The default.

Source

pub const fn lenient() -> Self

Every leniency.

Trait Implementations§

Source§

impl Clone for ParseOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for ParseOptions

Source§

impl Debug for ParseOptions

Source§

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

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

impl Default for ParseOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for ParseOptions

Source§

impl PartialEq for ParseOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ParseOptions

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.