Struct hls_m3u8::types::KeyFormatVersions[][src]

pub struct KeyFormatVersions { /* fields omitted */ }
Expand description

A list of numbers that can be used to indicate which version(s) this instance complies with, if more than one version of a particular KeyFormat is defined.

Note on maximum size

To reduce the memory usage and to make this struct implement Copy, a fixed size array is used internally ([u8; 9]), which can store a maximum number of 9 u8 numbers.

If you encounter any m3u8 file, which fails to parse, because the buffer is too small, feel free to make an issue.

Example

use hls_m3u8::types::KeyFormatVersions;

assert_eq!(
    KeyFormatVersions::from([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]).to_string(),
    "\"255/255/255/255/255/255/255/255/255\"".to_string()
);

Implementations

Constructs an empty KeyFormatVersions.

Example

let versions = KeyFormatVersions::new();

assert_eq!(versions, KeyFormatVersions::default());

Add a value to the end of KeyFormatVersions.

Panics

This function panics, if you try to push more elements, than KeyFormatVersions::remaining returns.

Example

let mut versions = KeyFormatVersions::new();

versions.push(1);
assert_eq!(versions, KeyFormatVersions::from([1]));

This will panic, because it exceeded the maximum number of elements:

let mut versions = KeyFormatVersions::new();

for _ in 0..=versions.capacity() {
    versions.push(1); // <- panics
}

KeyFormatVersions has a limited capacity and this function returns how many elements can be pushed, until it panics.

Example

let mut versions = KeyFormatVersions::new();

assert_eq!(versions.remaining(), versions.capacity());

versions.push(1);
versions.push(2);
versions.push(3);
assert_eq!(versions.remaining(), 6);

Returns the number of elements.

Example

let mut versions = KeyFormatVersions::new();

assert_eq!(versions.len(), 0);

versions.push(2);
assert_eq!(versions.len(), 1);

Returns the total number of elements that can be stored.

Note

It should not be relied on that this function will always return 9. In the future this number might increase.

Shortens the internal array to the provided length.

Note

If len is greater than the current length, this has no effect.

Example

let mut versions = KeyFormatVersions::from([1, 2, 3, 4, 5, 6]);
versions.truncate(3);

assert_eq!(versions, KeyFormatVersions::from([1, 2, 3]));

Returns true if there are no elements.

Example

let mut versions = KeyFormatVersions::new();

assert_eq!(versions.is_empty(), true);

versions.push(2);
assert_eq!(versions.is_empty(), false);

Removes the last element and returns it, or None if it is empty.

Example

let mut versions = KeyFormatVersions::new();

assert_eq!(versions.pop(), None);

versions.push(2);
assert_eq!(versions.pop(), Some(2));
assert_eq!(versions.is_empty(), true);

Returns true, if it is either empty or has a length of 1 and the first element is 1.

Example

let mut versions = KeyFormatVersions::new();

assert_eq!(versions.is_default(), true);

versions.push(1);
assert_eq!(versions.is_default(), true);

assert_eq!(KeyFormatVersions::default().is_default(), true);

Trait Implementations

Performs the conversion.

Performs the conversion.

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

Extends a collection with the contents of an iterator. Read more

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

Extends a collection with exactly one element.

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

Reserves capacity in a collection for the given number of additional elements. Read more

Extends a collection with the contents of an iterator. Read more

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

Extends a collection with exactly one element.

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

Reserves capacity in a collection for the given number of additional elements. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Creates a value from an iterator. Read more

Creates a value from an iterator. Read more

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

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

Which kind of iterator are we turning this into?

The type of the elements being iterated over.

Creates an iterator from a value. 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.

Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca) Read more

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA) Read more

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.