cloudcover_core/
sdk_method_mapping.rs1use serde::{Deserialize, Serialize};
2
3use crate::{ApiMethod, MethodReference, Sdk};
4
5#[derive(Clone, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
6pub struct SdkMethodMapping {
7 sdk: Sdk,
8 method: MethodReference,
9 api_methods: Vec<ApiMethod>,
10 #[serde(default, skip_serializing_if = "Vec::is_empty")]
11 unresolved_api_methods: Vec<ApiMethod>,
12}
13
14impl SdkMethodMapping {
15 #[must_use]
16 pub fn new(sdk: Sdk, method: MethodReference, api_methods: Vec<ApiMethod>) -> Self {
17 Self {
18 sdk,
19 method,
20 api_methods,
21 unresolved_api_methods: Vec::new(),
22 }
23 }
24
25 #[must_use]
26 pub fn sdk(&self) -> &Sdk {
27 &self.sdk
28 }
29
30 #[must_use]
31 pub fn method(&self) -> &MethodReference {
32 &self.method
33 }
34
35 #[must_use]
36 pub fn api_methods(&self) -> &[ApiMethod] {
37 &self.api_methods
38 }
39}
40
41impl SdkMethodMapping {
42 #[must_use]
44 pub fn with_unresolved_api_methods(mut self, mut methods: Vec<ApiMethod>) -> Self {
45 methods.sort();
46 methods.dedup();
47 self.unresolved_api_methods = methods;
48 self
49 }
50
51 #[must_use]
52 pub fn unresolved_api_methods(&self) -> &[ApiMethod] {
53 &self.unresolved_api_methods
54 }
55
56 #[must_use]
59 pub fn is_complete(&self) -> bool {
60 self.unresolved_api_methods.is_empty()
61 }
62}