Crate pls [−] [src]
Parser and writer for the PLS
playlist format.
Examples
Reading PLS':
assert_eq!(pls::parse(&mut &b"[playlist]\n\ File1=Track 1.mp3\n\ Title1=Unknown Artist - Track 1\n\ \n\ File2=Track 2.mp3\n\ Length2=420\n\ \n\ File3=Track 3.mp3\n\ Length3=-1\n\ \n\ NumberOfEntries=3\n"[..]).unwrap(), vec![PlaylistElement { path: "Track 1.mp3".to_string(), title: Some("Unknown Artist - Track 1".to_string()), len: ElementLength::Unknown, }, PlaylistElement { path: "Track 2.mp3".to_string(), title: None, len: ElementLength::Seconds(420), }, PlaylistElement { path: "Track 3.mp3".to_string(), title: None, len: ElementLength::Unknown, }]);
Writing PLS':
let mut buf = Vec::new(); pls::write(&[PlaylistElement { path: "Track 1.mp3".to_string(), title: Some("Unknown Artist - Track 1".to_string()), len: ElementLength::Unknown, }, PlaylistElement { path: "Track 2.mp3".to_string(), title: None, len: ElementLength::Seconds(420), }, PlaylistElement { path: "Track 3.mp3".to_string(), title: None, len: ElementLength::Unknown, }], &mut buf).unwrap(); assert_eq!(String::from_utf8(buf).unwrap(), "[playlist]\n\ File1=Track 1.mp3\n\ Title1=Unknown Artist - Track 1\n\ \n\ File2=Track 2.mp3\n\ Length2=420\n\ \n\ File3=Track 3.mp3\n\ \n\ NumberOfEntries=3\n\ Version=2\n")
Structs
PlaylistElement |
A single element of a playlist |
Enums
ElementLength |
Playlist element's length |
ParseError |
All ways parsing can fail |
Functions
parse |
Parse a playlist |
write |
Write a playlist to the specified output stream |