You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by ms...@apache.org on 2020/03/05 22:15:58 UTC
[incubator-teaclave] branch develop updated: [types] Add
constructors to FunctionInput/FunctionOutput
This is an automated email from the ASF dual-hosted git repository.
mssun pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git
The following commit(s) were added to refs/heads/develop by this push:
new 99d28b2 [types] Add constructors to FunctionInput/FunctionOutput
99d28b2 is described below
commit 99d28b2375b8114d0c555b1c327683373dc32d3f
Author: Mingshen Sun <bo...@mssun.me>
AuthorDate: Thu Mar 5 14:03:21 2020 -0800
[types] Add constructors to FunctionInput/FunctionOutput
---
services/management/enclave/src/service.rs | 35 +++++-----------------
.../enclave/src/teaclave_management_service.rs | 23 +++-----------
types/src/function.rs | 18 +++++++++++
3 files changed, 29 insertions(+), 47 deletions(-)
diff --git a/services/management/enclave/src/service.rs b/services/management/enclave/src/service.rs
index 94a110c..ab55ffe 100644
--- a/services/management/enclave/src/service.rs
+++ b/services/management/enclave/src/service.rs
@@ -560,22 +560,10 @@ impl TeaclaveManagementService {
input_file.uuid = Uuid::parse_str("00000000-0000-0000-0000-000000000002")?;
self.write_to_db(&input_file)?;
- let function_input = FunctionInput {
- name: "input".to_string(),
- description: "input_desc".to_string(),
- };
- let function_output = FunctionOutput {
- name: "output".to_string(),
- description: "output_desc".to_string(),
- };
- let function_input2 = FunctionInput {
- name: "input2".to_string(),
- description: "input_desc".to_string(),
- };
- let function_output2 = FunctionOutput {
- name: "output2".to_string(),
- description: "output_desc".to_string(),
- };
+ let function_input = FunctionInput::new("input", "input_desc");
+ let function_output = FunctionOutput::new("output", "output_desc");
+ let function_input2 = FunctionInput::new("input2", "input_desc");
+ let function_output2 = FunctionOutput::new("output2", "output_desc");
let native_function = Function {
function_id: Uuid::parse_str("00000000-0000-0000-0000-000000000001")?,
@@ -592,10 +580,7 @@ impl TeaclaveManagementService {
self.write_to_db(&native_function)?;
- let function_output = FunctionOutput {
- name: "output".to_string(),
- description: "output_desc".to_string(),
- };
+ let function_output = FunctionOutput::new("output", "output_desc");
let native_function = Function {
function_id: Uuid::parse_str("00000000-0000-0000-0000-000000000002")?,
name: "mock-native-func".to_string(),
@@ -710,14 +695,8 @@ pub mod tests {
}
pub fn handle_function() {
- let function_input = FunctionInput {
- name: "input".to_string(),
- description: "input_desc".to_string(),
- };
- let function_output = FunctionOutput {
- name: "output".to_string(),
- description: "output_desc".to_string(),
- };
+ let function_input = FunctionInput::new("input", "input_desc");
+ let function_output = FunctionOutput::new("output", "output_desc");
let function = Function {
function_id: Uuid::new_v4(),
name: "mock_function".to_string(),
diff --git a/tests/functional/enclave/src/teaclave_management_service.rs b/tests/functional/enclave/src/teaclave_management_service.rs
index 625df54..54cdfc6 100644
--- a/tests/functional/enclave/src/teaclave_management_service.rs
+++ b/tests/functional/enclave/src/teaclave_management_service.rs
@@ -3,9 +3,6 @@ use std::prelude::v1::*;
use teaclave_attestation::verifier;
use teaclave_config::RuntimeConfig;
use teaclave_config::BUILD_CONFIG;
-//use teaclave_proto::teaclave_frontend_service::{
-// DataOwnerList, FunctionInput, FunctionOutput, TaskStatus,
-//};
use teaclave_proto::teaclave_management_service::*;
use teaclave_rpc::config::SgxTrustedTlsClientConfig;
use teaclave_rpc::endpoint::Endpoint;
@@ -192,14 +189,8 @@ fn test_get_input_file() {
}
fn test_register_function() {
- let function_input = FunctionInput {
- name: "input".to_string(),
- description: "input_desc".to_string(),
- };
- let function_output = FunctionOutput {
- name: "output".to_string(),
- description: "output_desc".to_string(),
- };
+ let function_input = FunctionInput::new("input", "input_desc");
+ let function_output = FunctionOutput::new("output", "output_desc");
let request = RegisterFunctionRequest {
name: "mock_function".to_string(),
description: "mock function".to_string(),
@@ -217,14 +208,8 @@ fn test_register_function() {
}
fn test_get_function() {
- let function_input = FunctionInput {
- name: "input".to_string(),
- description: "input_desc".to_string(),
- };
- let function_output = FunctionOutput {
- name: "output".to_string(),
- description: "output_desc".to_string(),
- };
+ let function_input = FunctionInput::new("input", "input_desc");
+ let function_output = FunctionOutput::new("output", "output_desc");
let request = RegisterFunctionRequest {
name: "mock_function".to_string(),
description: "mock function".to_string(),
diff --git a/types/src/function.rs b/types/src/function.rs
index a125825..94ca8f7 100644
--- a/types/src/function.rs
+++ b/types/src/function.rs
@@ -26,12 +26,30 @@ pub struct FunctionInput {
pub description: String,
}
+impl FunctionInput {
+ pub fn new(name: impl Into<String>, description: impl Into<String>) -> Self {
+ Self {
+ name: name.into(),
+ description: description.into(),
+ }
+ }
+}
+
#[derive(Debug, Deserialize, Serialize)]
pub struct FunctionOutput {
pub name: String,
pub description: String,
}
+impl FunctionOutput {
+ pub fn new(name: impl Into<String>, description: impl Into<String>) -> Self {
+ Self {
+ name: name.into(),
+ description: description.into(),
+ }
+ }
+}
+
const FUNCION_PREFIX: &str = "function";
#[derive(Debug, Deserialize, Serialize)]
pub struct Function {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org