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
use super::*;
use crate::prelude::Source;
use std::iter::empty;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LoadedSourcesArguments {}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LoadedSourcesResponse {
pub sources: Vec<Source>,
}
impl From<LoadedSourcesArguments> for Value {
fn from(_: LoadedSourcesArguments) -> Self {
utils::finalize_object(empty())
}
}
impl From<&Map<String, Value>> for LoadedSourcesArguments {
fn from(_: &Map<String, Value>) -> Self {
Self {}
}
}
impl From<LoadedSourcesResponse> for Value {
fn from(args: LoadedSourcesResponse) -> Self {
let LoadedSourcesResponse { sources } = args;
let sources = utils::attribute_optional("sources", Some(sources));
utils::finalize_object(sources)
}
}
impl TryFrom<&Map<String, Value>> for LoadedSourcesResponse {
type Error = Error;
fn try_from(map: &Map<String, Value>) -> Result<Self, Self::Error> {
let sources = utils::get_array_optional(map, "sources")?;
Ok(Self { sources })
}
}