sile / hls_m3u8

HLS(RFC8216) m3u8 parser/generator
Apache License 2.0
49 stars 17 forks source link

Linting m3u8 files like proc_macros? #45

Open Luro02 opened 4 years ago

Luro02 commented 4 years ago

I think I read somewhere, that Spans can work with arbitrary file formats and it is not limited to rust code. It would be cool to have an error, that when displayed does include the relevant code;

error: the file has to start with #EXTM3U
 --> tests/example.m3u8:1:1
  |
1 | #EXTM2U
  | ^^^^^^^
  |
Luro02 commented 4 years ago

This is not possible afaik, because we do not want to emit the span as a compiler error and instead as a Spannable<String> that is attached to an error.

Therefore I started reimplementing the spanning as a separate crate, that will ideally be no_std and that supports to_string.

Luro02 commented 4 years ago

I found 3 crates, which let you span m3u8 files:

dholroyd commented 4 years ago

I would personally love to have span metadata (optionally?) for all parsed elements, not just from errors.

Motivation would be enabling code using this crate to support rendering diagnostics like:

error: the referenced media segment could not be retrieved
 --> http://media.example.com/example.m3u8:7:1
  | 
7 | second.ts
  | ^^^^^^^^^  HTTP 404
= note: 404 for URL http://media.example.com/second.ts

or

error: media segment duration descrepancy
 --> tests/example.m3u8:7:1
  | 
6 | #EXTINF:9.009,
            ^^^^^ manifest declared duration is 9.009
7 | second.ts
  | ^^^^^^^^^  but this segment's actual duration is 18.018