1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2025-04-05 19:49:36 +00:00

finish documentation

This commit is contained in:
Luro02 2020-03-28 10:51:19 +01:00
parent 9a2cacf024
commit 899aea7fc1
No known key found for this signature in database
GPG key ID: B66FD4F74501A9CF
3 changed files with 38 additions and 0 deletions

View file

@ -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;

View file

@ -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<MediaPlaylist, String> {
// validate builder
self.validate()?;

View file

@ -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<I: Into<String>>(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() }