Struct hls_m3u8::tags::ExtXKey[][src]

pub struct ExtXKey<'a>(pub Option<DecryptionKey<'a>>);
Expand description

Specifies how to decrypt encrypted data from the server.

An unencrypted segment should be marked with ExtXKey::empty.

Tuple Fields

0: Option<DecryptionKey<'a>>

Implementations

Constructs an ExtXKey tag.

Example

use hls_m3u8::types::{DecryptionKey, EncryptionMethod, KeyFormat};

let key = ExtXKey::new(
    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(vec![1, 2, 3, 4, 5])
        .build()?,
);

Constructs an empty ExtXKey, which signals that a segment is unencrypted.

Example

assert_eq!(ExtXKey::empty(), ExtXKey(None));

Returns true if the key is not empty.

Example

use hls_m3u8::types::{DecryptionKey, EncryptionMethod};

let k = ExtXKey::new(DecryptionKey::new(
    EncryptionMethod::Aes128,
    "https://www.example.url",
));
assert_eq!(k.is_some(), true);

let k = ExtXKey::empty();
assert_eq!(k.is_some(), false);

Returns true if the key is empty.

Example

use hls_m3u8::types::{DecryptionKey, EncryptionMethod};

let k = ExtXKey::new(DecryptionKey::new(
    EncryptionMethod::Aes128,
    "https://www.example.url",
));
assert_eq!(k.is_none(), false);

let k = ExtXKey::empty();
assert_eq!(k.is_none(), true);

Returns the underlying DecryptionKey, if there is one.

Panics

Panics if there is no underlying decryption key.

Examples

use hls_m3u8::types::{DecryptionKey, EncryptionMethod};

let k = ExtXKey::new(DecryptionKey::new(
    EncryptionMethod::Aes128,
    "https://www.example.url",
));

assert_eq!(
    k.unwrap(),
    DecryptionKey::new(EncryptionMethod::Aes128, "https://www.example.url")
);
use hls_m3u8::types::DecryptionKey;

let decryption_key: DecryptionKey = ExtXKey::empty().unwrap(); // panics

Returns a reference to the underlying DecryptionKey.

Converts an ExtXKey into an Option<DecryptionKey>.

Example

use hls_m3u8::types::{DecryptionKey, EncryptionMethod};

assert_eq!(ExtXKey::empty().into_option(), None);

assert_eq!(
    ExtXKey::new(DecryptionKey::new(
        EncryptionMethod::Aes128,
        "https://www.example.url"
    ))
    .into_option(),
    Some(DecryptionKey::new(
        EncryptionMethod::Aes128,
        "https://www.example.url"
    ))
);

Makes the struct independent of its lifetime, by taking ownership of all internal Cows.

Note

This is a relatively expensive operation.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.