1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-05-11 13:02:55 +00:00
hls_m3u8/src/lib.rs

146 lines
4 KiB
Rust
Raw Normal View History

2021-08-02 22:11:16 +00:00
#![doc(html_root_url = "https://docs.rs/hls_m3u8/0.4.1")]
2019-09-22 18:33:40 +00:00
#![forbid(unsafe_code)]
2020-04-09 06:43:13 +00:00
#![warn(rust_2018_idioms)]
2019-09-08 10:23:33 +00:00
#![warn(
2020-01-23 16:57:57 +00:00
clippy::pedantic, //
2019-09-08 10:23:33 +00:00
clippy::nursery,
2020-03-08 09:00:39 +00:00
clippy::cargo,
clippy::inline_always,
2019-09-08 10:23:33 +00:00
)]
2020-02-02 13:33:57 +00:00
#![allow(
2020-08-11 09:13:14 +00:00
clippy::non_ascii_literal,
clippy::redundant_pub_crate,
2020-02-02 13:33:57 +00:00
clippy::multiple_crate_versions,
clippy::module_name_repetitions,
2020-03-08 09:00:39 +00:00
clippy::default_trait_access,
clippy::unnecessary_operation // temporary until derive-builder uses #[allow(clippy::all)]
)]
#![warn(
clippy::clone_on_ref_ptr,
clippy::decimal_literal_representation,
clippy::get_unwrap,
2020-08-11 09:13:14 +00:00
clippy::expect_used,
2020-03-08 09:00:39 +00:00
clippy::unneeded_field_pattern,
clippy::wrong_pub_self_convention
)]
// those should not be present in production code:
#![deny(
clippy::print_stdout,
clippy::todo,
clippy::unimplemented,
clippy::dbg_macro,
clippy::use_debug
2020-02-02 13:33:57 +00:00
)]
2019-09-22 18:33:40 +00:00
#![warn(
missing_docs,
missing_copy_implementations,
missing_debug_implementations,
2020-02-10 12:21:48 +00:00
trivial_casts,
2019-09-22 18:33:40 +00:00
trivial_numeric_casts
)]
2018-02-14 03:00:41 +00:00
//! [HLS] m3u8 parser/generator.
//!
//! # Examples
//!
2018-02-14 19:55:28 +00:00
//! ```
//! use hls_m3u8::MediaPlaylist;
//! use std::convert::TryFrom;
2018-02-14 19:55:28 +00:00
//!
//! let m3u8 = MediaPlaylist::try_from(concat!(
//! "#EXTM3U\n",
//! "#EXT-X-TARGETDURATION:10\n",
//! "#EXT-X-VERSION:3\n",
//! "#EXTINF:9.009,\n",
//! "http://media.example.com/first.ts\n",
//! "#EXTINF:9.009,\n",
//! "http://media.example.com/second.ts\n",
//! "#EXTINF:3.003,\n",
//! "http://media.example.com/third.ts\n",
//! "#EXT-X-ENDLIST",
//! ));
2018-02-14 19:55:28 +00:00
//!
//! assert!(m3u8.is_ok());
2018-02-14 19:55:28 +00:00
//! ```
2020-02-24 15:45:10 +00:00
//!
2020-04-09 06:54:56 +00:00
//! ## Crate Feature Flags
//!
//! The following crate feature flags are available:
//!
//! - [`backtrace`] (optional)
//! - Enables the backtrace feature for the `Error` type.
//! - This feature depends on the following dependencies:
//! - [`backtrace`]
//! - [`chrono`] (optional)
//! - Enables parsing dates and verifying them.
//! - This feature depends on the following dependencies:
//! - [`chrono`]
//! - The following things will change:
//! - [`ExtXProgramDateTime::date_time`] will change from [`String`] to
//! `DateTime<FixedOffset>`
//! - [`ExtXDateRange::start_date`] will change from [`String`] to
//! `DateTime<FixedOffset>`
//! - [`ExtXDateRange::end_date`] will change from [`String`] to
//! `DateTime<FixedOffset>`
//!
//! They are configured in your `Cargo.toml` and can be enabled like this
//!
//! ```toml
//! hls_m3u8 = { version = "0.3", features = ["chrono", "backtrace"] }
//! ```
//!
//! [`ExtXProgramDateTime::date_time`]:
//! crate::tags::ExtXProgramDateTime::date_time
//! [`ExtXDateRange::start_date`]:
//! crate::tags::ExtXDateRange::start_date
//! [`ExtXDateRange::end_date`]:
//! crate::tags::ExtXDateRange::end_date
//! [`chrono`]: https://github.com/chronotope/chrono
//! [`backtrace`]: https://github.com/rust-lang/backtrace-rs
2020-02-24 15:45:10 +00:00
//! [HLS]: https://tools.ietf.org/html/rfc8216
2018-02-11 06:10:52 +00:00
2019-10-06 14:39:18 +00:00
pub use error::Error;
pub use master_playlist::MasterPlaylist;
pub use media_playlist::MediaPlaylist;
pub use media_segment::MediaSegment;
2018-02-11 06:10:52 +00:00
2020-03-28 09:51:19 +00:00
/// Builder structs
2020-03-25 13:10:59 +00:00
pub mod builder {
pub use crate::master_playlist::MasterPlaylistBuilder;
pub use crate::media_playlist::MediaPlaylistBuilder;
pub use crate::media_segment::MediaSegmentBuilder;
2020-03-28 09:51:19 +00:00
/// Builder structs for tags
2020-03-25 13:10:59 +00:00
pub mod tags {
// master playlist
pub use crate::tags::master_playlist::media::ExtXMediaBuilder;
pub use crate::tags::master_playlist::session_data::ExtXSessionDataBuilder;
// media segment
pub use crate::tags::media_segment::date_range::ExtXDateRangeBuilder;
// media playlist
}
2020-03-28 09:51:19 +00:00
/// Builder structs for types
2020-03-25 13:10:59 +00:00
pub mod types {
pub use crate::types::decryption_key::DecryptionKeyBuilder;
pub use crate::types::stream_data::StreamDataBuilder;
}
}
2018-02-14 19:51:44 +00:00
pub mod tags;
2018-02-14 03:16:36 +00:00
pub mod types;
2018-02-11 06:10:52 +00:00
2019-10-05 14:24:48 +00:00
#[macro_use]
mod utils;
2018-02-14 03:00:41 +00:00
mod attribute;
2018-02-11 06:10:52 +00:00
mod error;
2018-02-14 03:00:41 +00:00
mod line;
mod master_playlist;
mod media_playlist;
mod media_segment;
2019-10-04 09:02:21 +00:00
mod traits;
2018-02-11 06:10:52 +00:00
2019-09-13 14:06:52 +00:00
pub use error::Result;
2020-04-18 10:50:45 +00:00
pub use stable_vec;
2019-10-04 09:02:21 +00:00
pub use traits::*;