pub fn parse_playlist_res(input: &[u8]) -> Result<Playlist, Err<Error<&[u8]>>>
Expand description

Parses an m3u8 playlist just like parse_playlist, except that this returns an std::result::Result instead of a nom::IResult. However, since nom::IResult is now an alias to Result, this is no longer needed.

§Examples

use m3u8_rs::Playlist;
use std::io::Read;

let mut file = std::fs::File::open("playlist.m3u8").unwrap();
let mut bytes: Vec<u8> = Vec::new();
file.read_to_end(&mut bytes).unwrap();

let parsed = m3u8_rs::parse_playlist_res(&bytes);

match parsed {
    Ok(Playlist::MasterPlaylist(pl)) => println!("Master playlist:\n{:?}", pl),
    Ok(Playlist::MediaPlaylist(pl)) => println!("Media playlist:\n{:?}", pl),
    Err(e) => println!("Error: {:?}", e)
}
Examples found in repository?
examples/simple.rs (line 9)
4
5
6
7
8
9
10
11
12
13
14
15
16
fn main() {
    let mut file = std::fs::File::open("playlist.m3u8").unwrap();
    let mut bytes: Vec<u8> = Vec::new();
    file.read_to_end(&mut bytes).unwrap();

    let parsed = m3u8_rs::parse_playlist_res(&bytes);

    match parsed {
        Ok(Playlist::MasterPlaylist(pl)) => println!("Master playlist:\n{:?}", pl),
        Ok(Playlist::MediaPlaylist(pl)) => println!("Media playlist:\n{:?}", pl),
        Err(e) => println!("Error: {:?}", e),
    }
}