Skip to main content

flash_lso/types/
lso.rs

1use super::{AMFVersion, Element, Header};
2
3/// A container for lso files
4#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5#[derive(Debug, PartialEq, Clone)]
6pub struct Lso {
7    /// The header of this lso
8    pub header: Header,
9
10    /// The elements at the root level of this lso
11    pub body: Vec<Element>,
12}
13
14impl Lso {
15    /// Create a new Lso with a header with the given name and version and an empty body
16    #[inline]
17    pub fn new_empty(name: impl Into<String>, version: AMFVersion) -> Self {
18        Self::new(Vec::new(), name, version)
19    }
20
21    /// Crate a new Lso with a header with the given name, version and body
22    #[inline]
23    pub fn new(body: Vec<Element>, name: impl Into<String>, version: AMFVersion) -> Self {
24        Self {
25            header: Header::new(name, version),
26            body,
27        }
28    }
29}
30
31impl IntoIterator for Lso {
32    type Item = Element;
33    type IntoIter = std::vec::IntoIter<Self::Item>;
34
35    fn into_iter(self) -> Self::IntoIter {
36        self.body.into_iter()
37    }
38}