Skip to content

Commit

Permalink
feat: optimize dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nponsard committed Aug 29, 2023
1 parent 004fd22 commit 0c0934a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 24 deletions.
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ exclude = [
[dependencies]
serde = "^1.0"
serde_derive = "^1.0"
base64 = "0.21"
serde_json = "^1.0"
url = "^2.2"
uuid = { version = "^1.0", features = ["serde"] }
ureq = { version = "2", features = ["json"] }
ureq = { version = "2", features = ["json"] }
base64ct = { version = "1.6", features = ["alloc"] }
5 changes: 2 additions & 3 deletions docs/SystemInfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ Name | Type | Description | Notes
**hardware_version** | **String** | |
**build_tag** | **String** | |
**device_id** | **String** | |
**pcr** | **String** | |
**ak_pub_p256** | **String** | |
**ak_pub_p384** | **String** | |
**pcr** | [**serde_json::Value**](.md) | |
**ak_pub** | [**serde_json::Value**](.md) | |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ public CrustGenerator() {
typeMapping.put("double", "f64");
typeMapping.put("boolean", "bool");
typeMapping.put("string", "String");
typeMapping.put("UUID", "uuid::Uuid");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
typeMapping.put("date", "string");
typeMapping.put("date", "String");
typeMapping.put("DateTime", "String");
typeMapping.put("password", "String");
// TODO(bcourtine): review file mapping.
Expand Down
3 changes: 1 addition & 2 deletions generator/src/main/resources/crust/Cargo.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ serde_derive = "^1.0"
{{#serdeWith}}
serde_with = "^2.0"
{{/serdeWith}}
base64 = "0.21"
serde_json = "^1.0"
url = "^2.2"
uuid = { version = "^1.0", features = ["serde"] }
ureq = { version = "2", features = ["json"] }
base64ct = { version = "1.6", features = ["alloc"] }
5 changes: 3 additions & 2 deletions generator/src/main/resources/crust/reqwest/api_mod.mustache
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::error;
use std::fmt;
use std::collections::HashMap;
use base64::{engine::general_purpose, Engine};

use base64ct::{Base64, Encoding};

pub (crate) fn get_header_map(response : &ureq::Response) -> HashMap<String,String> {
Expand Down Expand Up @@ -110,7 +111,7 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String

pub(crate) fn basic_auth(auth: &configuration::BasicAuth) -> String {
let string = format!("{}:{}", auth.0, auth.1.as_ref().unwrap_or(&"".to_string()));
format!("Basic {}", general_purpose::STANDARD.encode(string)).to_string()
format!("Basic {}", Base64::encode_string(string.as_bytes()))
}

{{#apiInfo}}
Expand Down
5 changes: 3 additions & 2 deletions src/apis/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use base64::{engine::general_purpose, Engine};
use std::collections::HashMap;
use std::error;
use std::fmt;

use base64ct::{Base64, Encoding};

pub(crate) fn get_header_map(response: &ureq::Response) -> HashMap<String, String> {
let mut headers = HashMap::new();

Expand Down Expand Up @@ -110,7 +111,7 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String

pub(crate) fn basic_auth(auth: &configuration::BasicAuth) -> String {
let string = format!("{}:{}", auth.0, auth.1.as_ref().unwrap_or(&"".to_string()));
format!("Basic {}", general_purpose::STANDARD.encode(string)).to_string()
format!("Basic {}", Base64::encode_string(string.as_bytes()))
}

pub mod default_api;
Expand Down
16 changes: 6 additions & 10 deletions src/models/system_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ pub struct SystemInfo {
#[serde(rename = "deviceId")]
pub device_id: String,
#[serde(rename = "pcr")]
pub pcr: String,
#[serde(rename = "akPubP256")]
pub ak_pub_p256: String,
#[serde(rename = "akPubP384")]
pub ak_pub_p384: String,
pub pcr: serde_json::Value,
#[serde(rename = "akPub")]
pub ak_pub: serde_json::Value,
}

impl SystemInfo {
Expand All @@ -35,9 +33,8 @@ impl SystemInfo {
hardware_version: String,
build_tag: String,
device_id: String,
pcr: String,
ak_pub_p256: String,
ak_pub_p384: String,
pcr: serde_json::Value,
ak_pub: serde_json::Value,
) -> SystemInfo {
SystemInfo {
firmware_version,
Expand All @@ -46,8 +43,7 @@ impl SystemInfo {
build_tag,
device_id,
pcr,
ak_pub_p256,
ak_pub_p384,
ak_pub,
}
}
}

0 comments on commit 0c0934a

Please sign in to comment.