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.
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
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
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
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Performs the conversion.
Performs the conversion.
Creates a value from an iterator. Read more
Creates a value from an iterator. Read more
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
Auto Trait Implementations
impl RefUnwindSafe for KeyFormatVersions
impl Send for KeyFormatVersions
impl Sync for KeyFormatVersions
impl Unpin for KeyFormatVersions
impl UnwindSafe for KeyFormatVersions
Blanket Implementations
Mutably borrows from an owned value. Read more