Function subparse::get_subtitle_format_by_extension[][src]

pub fn get_subtitle_format_by_extension(
    extension: Option<&OsStr>
) -> Option<SubtitleFormat>

Returns the subtitle format by the file extension.

Calling the function with the full file path or simply a get_subtitle_format_by_extension(Some(OsStr::new("srt"))) both work. Returns None if subtitle format could not be recognized.

Because the .sub file extension is ambiguous (both MicroDVD and VobSub use that extension) the function will return None in that case. Instead, use the content-aware get_subtitle_format to handle this case correctly.

Option is used to simplify handling with PathBuf::extension().