Enum hls_m3u8::types::InitializationVector[][src]

#[non_exhaustive]
pub enum InitializationVector {
    Aes128([u8; 16]),
    Number(u128),
    Missing,
}
Expand description

An initialization vector (IV) is a fixed size input that can be used along with a secret key for data encryption.

The use of an IV prevents repetition in encrypted data, making it more difficult for a hacker using a dictionary attack to find patterns and break a cipher. For example, a sequence might appear twice or more within the body of a message. If there are repeated sequences in encrypted data, an attacker could assume that the corresponding sequences in the message were also identical. The IV prevents the appearance of corresponding duplicate character sequences in the ciphertext.

Variants (Non-exhaustive)

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Aes128

An IV for use with Aes128.

Tuple Fields of Aes128

0: [u8; 16]
Number

An ExtXKey tag with KeyFormat::Identity that does not have an IV field indicates that the MediaSegment::number is to be used as the IV when decrypting a MediaSegment.

Tuple Fields of Number

0: u128
Missing

Signals that an IV is missing.

Implementations

Returns the IV as an u128. None is returned for InitializationVector::Missing.

Example

assert_eq!(
    InitializationVector::Aes128([
        0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78,
        0x90, 0x12
    ])
    .to_u128(),
    Some(0x12345678901234567890123456789012)
);

assert_eq!(InitializationVector::Number(0x10).to_u128(), Some(0x10));

assert_eq!(InitializationVector::Missing.to_u128(), None);

Returns the IV as a slice, which can be used to for example decrypt a MediaSegment. None is returned for InitializationVector::Missing.

Example

assert_eq!(
    InitializationVector::Aes128([
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
        0x0F, 0x10,
    ])
    .to_slice(),
    Some([
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
        0x0F, 0x10,
    ])
);

assert_eq!(
    InitializationVector::Number(0x12345678901234567890123456789012).to_slice(),
    Some([
        0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78,
        0x90, 0x12
    ])
);

assert_eq!(InitializationVector::Missing.to_slice(), None);

Returns true if the initialization vector is not missing.

Example

assert_eq!(
    InitializationVector::Aes128([
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
        0x0F, 0x10,
    ])
    .is_some(),
    true
);

assert_eq!(InitializationVector::Number(4).is_some(), true);

assert_eq!(InitializationVector::Missing.is_some(), false);

Returns true if the initialization vector is missing.

Example

assert_eq!(
    InitializationVector::Aes128([
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
        0x0F, 0x10,
    ])
    .is_none(),
    false
);

assert_eq!(InitializationVector::Number(4).is_none(), false);

assert_eq!(InitializationVector::Missing.is_none(), true);

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

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

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

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.