1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use super::*;

/// ## JSON Array schema value
///
/// Runtime representation of a 'to-be-deserialized' JSON Array.
///
/// This object specify if the array is optional and describes its children.
///
///
/// ### Limitations
///
/// This objects cannot describe multiple types of childrens
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct MessyJsonArray {
    optional: bool,
    items: MessyJson,
}

impl MessyJsonArray {
    /// Create a new [MessyJsonArray](MessyJsonArray)
    pub fn new(items: MessyJson, optional: bool) -> Self {
        MessyJsonArray { items, optional }
    }

    /// Get the underlying items of a [MessyJsonArray](MessyJsonArray)
    #[inline]
    pub fn items(&self) -> &MessyJson {
        &self.items
    }

    /// Check if the array is optional
    #[inline]
    pub fn optional(&self) -> bool {
        self.optional
    }
}