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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use super::{expand_element, Expanded, Options};
use crate::{
context::{Loader, TermDefinition},
object::*,
syntax::ContainerType,
ContextMut, Error, Id,
};
use iref::Iri;
use json::JsonValue;
pub async fn expand_array<
T: Send + Sync + Id,
C: Send + Sync + ContextMut<T>,
L: Send + Sync + Loader,
>(
active_context: &C,
active_property: Option<&str>,
active_property_definition: Option<&TermDefinition<T, C>>,
element: &[JsonValue],
base_url: Option<Iri<'_>>,
loader: &mut L,
options: Options,
from_map: bool,
) -> Result<Expanded<T>, Error>
where
C::LocalContext: Send + Sync + From<L::Output> + From<JsonValue>,
L::Output: Into<JsonValue>,
{
let mut is_list = false;
let mut result = Vec::new();
if let Some(definition) = active_property_definition {
is_list = definition.container.contains(ContainerType::List);
}
for item in element {
result.extend(
expand_element(
active_context,
active_property,
item,
base_url,
loader,
options,
from_map,
)
.await?,
);
}
if is_list {
return Ok(Expanded::Object(Object::List(result).into()));
}
Ok(Expanded::Array(result))
}