diff --git a/src/lib.rs b/src/lib.rs index 3b7e3c6..70edb06 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,11 +62,13 @@ pub use master_playlist::MasterPlaylist; pub use media_playlist::MediaPlaylist; pub use media_segment::MediaSegment; +/// Builder structs pub mod builder { pub use crate::master_playlist::MasterPlaylistBuilder; pub use crate::media_playlist::MediaPlaylistBuilder; pub use crate::media_segment::MediaSegmentBuilder; + /// Builder structs for tags pub mod tags { // master playlist pub use crate::tags::master_playlist::media::ExtXMediaBuilder; @@ -78,6 +80,7 @@ pub mod builder { // media playlist } + /// Builder structs for types pub mod types { pub use crate::types::decryption_key::DecryptionKeyBuilder; pub use crate::types::stream_data::StreamDataBuilder; diff --git a/src/media_playlist.rs b/src/media_playlist.rs index 855aea8..9fb4aad 100644 --- a/src/media_playlist.rs +++ b/src/media_playlist.rs @@ -262,6 +262,11 @@ impl MediaPlaylistBuilder { self } + /// Builds a new `MediaPlaylist`. + /// + /// # Errors + /// + /// If a required field has not been initialized. pub fn build(&self) -> Result { // validate builder self.validate()?; diff --git a/src/types/decryption_key.rs b/src/types/decryption_key.rs index 0caf17a..53bff38 100644 --- a/src/types/decryption_key.rs +++ b/src/types/decryption_key.rs @@ -81,6 +81,17 @@ pub struct DecryptionKey { } impl DecryptionKey { + /// Creates a new `DecryptionKey` from an uri pointing to the key data and + /// an `EncryptionMethod`. + /// + /// # Example + /// + /// ``` + /// # use hls_m3u8::types::DecryptionKey; + /// use hls_m3u8::types::EncryptionMethod; + /// + /// let key = DecryptionKey::new(EncryptionMethod::Aes128, "https://www.example.uri/key"); + /// ``` #[must_use] #[inline] pub fn new>(method: EncryptionMethod, uri: I) -> Self { @@ -93,6 +104,25 @@ impl DecryptionKey { } } + /// Returns a builder for a `DecryptionKey`. + /// + /// # Example + /// + /// ``` + /// # use hls_m3u8::types::DecryptionKey; + /// use hls_m3u8::types::{EncryptionMethod, KeyFormat}; + /// + /// let key = DecryptionKey::builder() + /// .method(EncryptionMethod::Aes128) + /// .uri("https://www.example.com/") + /// .iv([ + /// 16, 239, 143, 117, 140, 165, 85, 17, 85, 132, 187, 91, 60, 104, 127, 82, + /// ]) + /// .format(KeyFormat::Identity) + /// .versions(&[1, 2, 3, 4, 5]) + /// .build()?; + /// # Ok::<(), String>(()) + /// ``` #[must_use] #[inline] pub fn builder() -> DecryptionKeyBuilder { DecryptionKeyBuilder::default() }