pub struct Parser<T: BufRead> { /* private fields */ }Expand description
A parser to parse M3U/M3U8 file.
Example:
use mediastream_rs::Parser;
use std::io::Cursor;
let mut parser = Parser::new(Cursor::new(r#"
#EXTM3U x-tvg-url="test"
#EXTINF:1 tvg-id="a" provider-type="iptv",A
http://example.com/A.m3u8"#));
parser.parse().unwrap();
let _result = parser.get_playlist();Implementations§
Source§impl<T: BufRead> Parser<T>
impl<T: BufRead> Parser<T>
Sourcepub fn new(reader: T) -> Self
pub fn new(reader: T) -> Self
Create a parser from a stream (BufRead + Seek + 'static)
Example:
use mediastream_rs::Parser;
use std::io::Cursor;
let mut parser = Parser::new(Cursor::new(r#"
#EXTM3U x-tvg-url="test"
#EXTINF:1 tvg-id="a" provider-type="iptv",A
http://example.com/A.m3u8"#));Sourcepub fn parse(&mut self) -> Result<(), ParseError>
pub fn parse(&mut self) -> Result<(), ParseError>
Parse the content from the stream until EOF, and return the error if occurred
Example:
use mediastream_rs::Parser;
use std::io::Cursor;
let mut parser = Parser::new(Cursor::new(r#"
#EXTM3U x-tvg-url="test"
#EXTINF:1 tvg-id="a" provider-type="iptv",A
http://example.com/A.m3u8"#));
parser.parse().unwrap();Sourcepub fn get_playlist(&mut self) -> M3uPlaylist
pub fn get_playlist(&mut self) -> M3uPlaylist
Get the parsed M3uPlaylist, and you can continue the next parsing
Example:
use mediastream_rs::Parser;
use std::io::Cursor;
let mut parser = Parser::new(Cursor::new(r#"
#EXTM3U x-tvg-url="test"
#EXTINF:1 tvg-id="a" provider-type="iptv",A
http://example.com/A.m3u8"#));
parser.parse().unwrap();
_ = parser.get_playlist();Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Return the inner reader
Example:
use mediastream_rs::Parser;
use std::io::Cursor;
let mut parser = Parser::new(Cursor::new(r#"
#EXTM3U x-tvg-url="test"
#EXTINF:1 tvg-id="a" provider-type="iptv",A
http://example.com/A.m3u8"#));
let _the_cursor = parser.into_inner();Auto Trait Implementations§
impl<T> Freeze for Parser<T>where
T: Freeze,
impl<T> RefUnwindSafe for Parser<T>where
T: RefUnwindSafe,
impl<T> Send for Parser<T>where
T: Send,
impl<T> Sync for Parser<T>where
T: Sync,
impl<T> Unpin for Parser<T>where
T: Unpin,
impl<T> UnsafeUnpin for Parser<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Parser<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more