This is an automated email from the ASF dual-hosted git repository.

yuanz pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/incubator-teaclave-trustzone-sdk.git

commit c529f43d18535b6223f8cfd2426c526fd5a08d37
Author: ivila <[email protected]>
AuthorDate: Mon Feb 17 16:04:27 2025 +0800

    examples & projects: simplify proto crate
    
    - truncate uuid.txt and remove build.rs
    - use num_enum for conversion between enum and u32
    
    Signed-off-by: Zehui Chen <[email protected]>
    Reviewed-by: Yuan Zhuang <[email protected]>
---
 examples/acipher-rs/proto/Cargo.toml               |  4 +-
 examples/acipher-rs/proto/build.rs                 | 36 ------------
 examples/acipher-rs/proto/src/lib.rs               | 22 +++-----
 examples/acipher-rs/uuid.txt                       |  2 +-
 examples/aes-rs/proto/Cargo.toml                   |  4 +-
 examples/aes-rs/proto/build.rs                     | 36 ------------
 examples/aes-rs/proto/src/lib.rs                   | 65 ++++++----------------
 examples/aes-rs/uuid.txt                           |  2 +-
 examples/authentication-rs/proto/Cargo.toml        |  4 +-
 examples/authentication-rs/proto/build.rs          | 36 ------------
 examples/authentication-rs/proto/src/lib.rs        | 36 ++++--------
 examples/authentication-rs/uuid.txt                |  2 +-
 examples/big_int-rs/proto/Cargo.toml               |  4 +-
 examples/big_int-rs/proto/build.rs                 | 36 ------------
 examples/big_int-rs/proto/src/lib.rs               | 25 +++------
 examples/big_int-rs/uuid.txt                       |  2 +-
 examples/diffie_hellman-rs/proto/Cargo.toml        |  4 +-
 examples/diffie_hellman-rs/proto/build.rs          | 36 ------------
 examples/diffie_hellman-rs/proto/src/lib.rs        | 20 +++----
 examples/diffie_hellman-rs/uuid.txt                |  2 +-
 examples/digest-rs/proto/Cargo.toml                |  4 +-
 examples/digest-rs/proto/build.rs                  | 36 ------------
 examples/digest-rs/proto/src/lib.rs                | 20 +++----
 examples/digest-rs/uuid.txt                        |  2 +-
 examples/error_handling-rs/proto/Cargo.toml        |  4 +-
 examples/error_handling-rs/proto/build.rs          | 36 ------------
 examples/error_handling-rs/proto/src/lib.rs        | 20 +++----
 examples/hello_world-rs/proto/Cargo.toml           |  4 +-
 examples/hello_world-rs/proto/build.rs             | 36 ------------
 examples/hello_world-rs/proto/src/lib.rs           | 20 +++----
 examples/hello_world-rs/uuid.txt                   |  2 +-
 examples/hotp-rs/proto/Cargo.toml                  |  4 +-
 examples/hotp-rs/proto/build.rs                    | 36 ------------
 examples/hotp-rs/proto/src/lib.rs                  | 20 +++----
 examples/hotp-rs/uuid.txt                          |  2 +-
 .../message_passing_interface-rs/proto/Cargo.toml  |  4 +-
 .../message_passing_interface-rs/proto/build.rs    | 36 ------------
 .../message_passing_interface-rs/proto/src/lib.rs  | 22 +++-----
 examples/message_passing_interface-rs/uuid.txt     |  2 +-
 examples/random-rs/proto/Cargo.toml                |  4 +-
 examples/random-rs/proto/build.rs                  | 36 ------------
 examples/random-rs/proto/src/lib.rs                | 19 +++----
 examples/random-rs/uuid.txt                        |  2 +-
 examples/secure_storage-rs/proto/Cargo.toml        |  4 +-
 examples/secure_storage-rs/proto/build.rs          | 36 ------------
 examples/secure_storage-rs/proto/src/lib.rs        | 21 +++----
 examples/secure_storage-rs/uuid.txt                |  2 +-
 examples/serde-rs/proto/Cargo.toml                 |  4 +-
 examples/serde-rs/proto/build.rs                   | 36 ------------
 examples/serde-rs/proto/src/lib.rs                 | 20 +++----
 examples/serde-rs/uuid.txt                         |  2 +-
 .../signature_verification-rs/proto/Cargo.toml     |  4 +-
 examples/signature_verification-rs/proto/build.rs  | 34 -----------
 .../signature_verification-rs/proto/src/lib.rs     | 20 +++----
 examples/signature_verification-rs/uuid.txt        |  2 +-
 examples/supp_plugin-rs/plugin_uuid.txt            |  2 +-
 examples/supp_plugin-rs/proto/Cargo.toml           |  4 +-
 examples/supp_plugin-rs/proto/build.rs             | 50 -----------------
 examples/supp_plugin-rs/proto/src/lib.rs           | 38 +++++--------
 examples/supp_plugin-rs/ta_uuid.txt                |  2 +-
 examples/tcp_client-rs/proto/Cargo.toml            |  3 -
 examples/tcp_client-rs/proto/build.rs              | 36 ------------
 examples/tcp_client-rs/proto/src/lib.rs            |  5 +-
 examples/tcp_client-rs/uuid.txt                    |  2 +-
 examples/time-rs/proto/Cargo.toml                  |  4 +-
 examples/time-rs/proto/build.rs                    | 36 ------------
 examples/time-rs/proto/src/lib.rs                  | 19 +++----
 examples/time-rs/uuid.txt                          |  2 +-
 examples/tls_client-rs/proto/Cargo.toml            |  4 +-
 examples/tls_client-rs/proto/build.rs              | 36 ------------
 examples/tls_client-rs/proto/src/lib.rs            | 20 +++----
 examples/tls_client-rs/uuid.txt                    |  2 +-
 examples/tls_server-rs/proto/Cargo.toml            |  4 +-
 examples/tls_server-rs/proto/build.rs              | 36 ------------
 examples/tls_server-rs/proto/src/lib.rs            | 23 +++-----
 examples/tls_server-rs/uuid.txt                    |  2 +-
 examples/udp_socket-rs/proto/Cargo.toml            |  3 -
 examples/udp_socket-rs/proto/build.rs              | 36 ------------
 examples/udp_socket-rs/proto/src/lib.rs            |  5 +-
 examples/udp_socket-rs/uuid.txt                    |  2 +-
 projects/web3/eth_wallet/proto/Cargo.toml          |  4 +-
 projects/web3/eth_wallet/proto/build.rs            | 36 ------------
 projects/web3/eth_wallet/proto/src/lib.rs          | 25 ++++-----
 projects/web3/eth_wallet/uuid.txt                  |  2 +-
 84 files changed, 224 insertions(+), 1153 deletions(-)

diff --git a/examples/acipher-rs/proto/Cargo.toml 
b/examples/acipher-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/acipher-rs/proto/Cargo.toml
+++ b/examples/acipher-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/acipher-rs/proto/build.rs 
b/examples/acipher-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/acipher-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/acipher-rs/proto/src/lib.rs 
b/examples/acipher-rs/proto/src/lib.rs
index 7c3f730..86a211c 100644
--- a/examples/acipher-rs/proto/src/lib.rs
+++ b/examples/acipher-rs/proto/src/lib.rs
@@ -16,26 +16,20 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     GenKey,
     GetSize,
     Encrypt,
     Decrypt,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::GenKey,
-            1 => Command::GetSize,
-            2 => Command::Encrypt, 
-            3 => Command::Decrypt,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/acipher-rs/uuid.txt b/examples/acipher-rs/uuid.txt
index e7097d8..cc86ae9 100644
--- a/examples/acipher-rs/uuid.txt
+++ b/examples/acipher-rs/uuid.txt
@@ -1 +1 @@
-057f4b66-bdab-11eb-96cf-33d6e41cc849
+057f4b66-bdab-11eb-96cf-33d6e41cc849
\ No newline at end of file
diff --git a/examples/aes-rs/proto/Cargo.toml b/examples/aes-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/aes-rs/proto/Cargo.toml
+++ b/examples/aes-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/aes-rs/proto/build.rs b/examples/aes-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/aes-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/aes-rs/proto/src/lib.rs b/examples/aes-rs/proto/src/lib.rs
index bf59ad1..347097d 100644
--- a/examples/aes-rs/proto/src/lib.rs
+++ b/examples/aes-rs/proto/src/lib.rs
@@ -16,79 +16,48 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     Prepare,
     SetKey,
     SetIV,
     Cipher,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::Prepare,
-            1 => Command::SetKey,
-            2 => Command::SetIV,
-            3 => Command::Cipher,
-            _ => Command::Unknown,
-        }
-    }
-}
-
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Algo {
     ECB,
     CBC,
     CTR,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Algo {
-    #[inline]
-    fn from(value: u32) -> Algo {
-        match value {
-            0 => Algo::ECB,
-            1 => Algo::CBC,
-            2 => Algo::CTR,
-            _ => Algo::Unknown,
-        }
-    }
-}
-
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Mode {
     Decode,
     Encode,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Mode {
-    #[inline]
-    fn from(value: u32) -> Mode {
-        match value {
-            0 => Mode::Decode,
-            1 => Mode::Encode,
-            _ => Mode::Unknown,
-        }
-    }
-}
-
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum KeySize {
     Bit128 = 16,
     Bit256 = 32,
+    #[default]
     Unknown = 0,
 }
 
-impl From<u32> for KeySize {
-    #[inline]
-    fn from(value: u32) -> KeySize {
-        match value {
-            16 => KeySize::Bit128,
-            32 => KeySize::Bit256,
-            _ => KeySize::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/aes-rs/uuid.txt b/examples/aes-rs/uuid.txt
index ea86311..8def748 100644
--- a/examples/aes-rs/uuid.txt
+++ b/examples/aes-rs/uuid.txt
@@ -1 +1 @@
-0864c8ec-bdab-11eb-8926-c7fa47a8c92d
+0864c8ec-bdab-11eb-8926-c7fa47a8c92d
\ No newline at end of file
diff --git a/examples/authentication-rs/proto/Cargo.toml 
b/examples/authentication-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/authentication-rs/proto/Cargo.toml
+++ b/examples/authentication-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/authentication-rs/proto/build.rs 
b/examples/authentication-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/authentication-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/authentication-rs/proto/src/lib.rs 
b/examples/authentication-rs/proto/src/lib.rs
index 33fc4d8..f5c3a37 100644
--- a/examples/authentication-rs/proto/src/lib.rs
+++ b/examples/authentication-rs/proto/src/lib.rs
@@ -16,48 +16,34 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     Prepare,
     Update,
     EncFinal,
     DecFinal,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::Prepare,
-            1 => Command::Update,
-            2 => Command::EncFinal,
-            3 => Command::DecFinal,
-            _ => Command::Unknown,
-        }
-    }
-}
-
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Mode {
     Encrypt,
     Decrypt,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Mode {
-    #[inline]
-    fn from(value: u32) -> Mode {
-        match value {
-            0 => Mode::Encrypt,
-            1 => Mode::Decrypt,
-            _ => Mode::Unknown,
-        }
-    }
-}
-
 pub const BUFFER_SIZE: usize = 16;
 pub const KEY_SIZE: usize = 16;
 pub const AAD_LEN: usize = 16;
 pub const TAG_LEN: usize = 16;
 
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/authentication-rs/uuid.txt 
b/examples/authentication-rs/uuid.txt
index af8389a..c3756bf 100644
--- a/examples/authentication-rs/uuid.txt
+++ b/examples/authentication-rs/uuid.txt
@@ -1 +1 @@
-0a5a06b2-bdab-11eb-add0-77f29de31296
+0a5a06b2-bdab-11eb-add0-77f29de31296
\ No newline at end of file
diff --git a/examples/big_int-rs/proto/Cargo.toml 
b/examples/big_int-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/big_int-rs/proto/Cargo.toml
+++ b/examples/big_int-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/big_int-rs/proto/build.rs 
b/examples/big_int-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/big_int-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/big_int-rs/proto/src/lib.rs 
b/examples/big_int-rs/proto/src/lib.rs
index aeaa8d3..68b6f00 100644
--- a/examples/big_int-rs/proto/src/lib.rs
+++ b/examples/big_int-rs/proto/src/lib.rs
@@ -16,7 +16,10 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     Compare,
     Convert,
@@ -25,23 +28,11 @@ pub enum Command {
     Multiply,
     Divide,
     Module,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::Compare,
-            1 => Command::Convert,
-            2 => Command::Add,
-            3 => Command::Sub,
-            4 => Command::Multiply,
-            5 => Command::Divide,
-            6 => Command::Module,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/big_int-rs/uuid.txt b/examples/big_int-rs/uuid.txt
index efa7d54..989765b 100644
--- a/examples/big_int-rs/uuid.txt
+++ b/examples/big_int-rs/uuid.txt
@@ -1 +1 @@
-0bef16a2-bdab-11eb-94be-6f9815f37c21
+0bef16a2-bdab-11eb-94be-6f9815f37c21
\ No newline at end of file
diff --git a/examples/diffie_hellman-rs/proto/Cargo.toml 
b/examples/diffie_hellman-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/diffie_hellman-rs/proto/Cargo.toml
+++ b/examples/diffie_hellman-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/diffie_hellman-rs/proto/build.rs 
b/examples/diffie_hellman-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/diffie_hellman-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/diffie_hellman-rs/proto/src/lib.rs 
b/examples/diffie_hellman-rs/proto/src/lib.rs
index 6dfdc5f..a34b832 100644
--- a/examples/diffie_hellman-rs/proto/src/lib.rs
+++ b/examples/diffie_hellman-rs/proto/src/lib.rs
@@ -16,24 +16,20 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     GenerateKey,
     DeriveKey,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::GenerateKey,
-            1 => Command::DeriveKey,
-            _ => Command::Unknown,
-        }
-    }
-}
-
 pub const KEY_SIZE: usize = 256;
 
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/diffie_hellman-rs/uuid.txt 
b/examples/diffie_hellman-rs/uuid.txt
index 4a6efb7..d5b1c92 100644
--- a/examples/diffie_hellman-rs/uuid.txt
+++ b/examples/diffie_hellman-rs/uuid.txt
@@ -1 +1 @@
-0e6bf4fe-bdab-11eb-9bc5-3f4ecb50aee7
+0e6bf4fe-bdab-11eb-9bc5-3f4ecb50aee7
\ No newline at end of file
diff --git a/examples/digest-rs/proto/Cargo.toml 
b/examples/digest-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/digest-rs/proto/Cargo.toml
+++ b/examples/digest-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/digest-rs/proto/build.rs 
b/examples/digest-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/digest-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/digest-rs/proto/src/lib.rs 
b/examples/digest-rs/proto/src/lib.rs
index e27b36d..a19278d 100644
--- a/examples/digest-rs/proto/src/lib.rs
+++ b/examples/digest-rs/proto/src/lib.rs
@@ -16,22 +16,18 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     Update,
     DoFinal,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::Update,
-            1 => Command::DoFinal,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/digest-rs/uuid.txt b/examples/digest-rs/uuid.txt
index 062006d..322fa1a 100644
--- a/examples/digest-rs/uuid.txt
+++ b/examples/digest-rs/uuid.txt
@@ -1 +1 @@
-10de87e2-bdab-11eb-b73c-63fec73e597c
+10de87e2-bdab-11eb-b73c-63fec73e597c
\ No newline at end of file
diff --git a/examples/error_handling-rs/proto/Cargo.toml 
b/examples/error_handling-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/error_handling-rs/proto/Cargo.toml
+++ b/examples/error_handling-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/error_handling-rs/proto/build.rs 
b/examples/error_handling-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/error_handling-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/error_handling-rs/proto/src/lib.rs 
b/examples/error_handling-rs/proto/src/lib.rs
index 74f3a8a..a385501 100644
--- a/examples/error_handling-rs/proto/src/lib.rs
+++ b/examples/error_handling-rs/proto/src/lib.rs
@@ -16,24 +16,20 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     // Ask the TA to simply return `TEE_SUCCESS` when handling this command.
     ReturnSuccess,
     // Ask the TA to simply return `TEE_ERROR_GENERIC` when handling this 
command.
     ReturnGenericError,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::ReturnSuccess,
-            1 => Command::ReturnGenericError,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/hello_world-rs/proto/Cargo.toml 
b/examples/hello_world-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/hello_world-rs/proto/Cargo.toml
+++ b/examples/hello_world-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/hello_world-rs/proto/build.rs 
b/examples/hello_world-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/hello_world-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/hello_world-rs/proto/src/lib.rs 
b/examples/hello_world-rs/proto/src/lib.rs
index 5fe3f74..6299cf9 100644
--- a/examples/hello_world-rs/proto/src/lib.rs
+++ b/examples/hello_world-rs/proto/src/lib.rs
@@ -16,22 +16,18 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     IncValue,
     DecValue,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::IncValue,
-            1 => Command::DecValue,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/hello_world-rs/uuid.txt b/examples/hello_world-rs/uuid.txt
index 9f4a184..7f63353 100644
--- a/examples/hello_world-rs/uuid.txt
+++ b/examples/hello_world-rs/uuid.txt
@@ -1 +1 @@
-133af0ca-bdab-11eb-9130-43bf7873bf67
+133af0ca-bdab-11eb-9130-43bf7873bf67
\ No newline at end of file
diff --git a/examples/hotp-rs/proto/Cargo.toml 
b/examples/hotp-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/hotp-rs/proto/Cargo.toml
+++ b/examples/hotp-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/hotp-rs/proto/build.rs b/examples/hotp-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/hotp-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/hotp-rs/proto/src/lib.rs 
b/examples/hotp-rs/proto/src/lib.rs
index 2831d81..44599d4 100644
--- a/examples/hotp-rs/proto/src/lib.rs
+++ b/examples/hotp-rs/proto/src/lib.rs
@@ -16,22 +16,18 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     RegisterSharedKey,
     GetHOTP,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::RegisterSharedKey,
-            1 => Command::GetHOTP,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/hotp-rs/uuid.txt b/examples/hotp-rs/uuid.txt
index 461a084..69add6a 100644
--- a/examples/hotp-rs/uuid.txt
+++ b/examples/hotp-rs/uuid.txt
@@ -1 +1 @@
-1585d412-bdab-11eb-ba91-3b085fd2601f
+1585d412-bdab-11eb-ba91-3b085fd2601f
\ No newline at end of file
diff --git a/examples/message_passing_interface-rs/proto/Cargo.toml 
b/examples/message_passing_interface-rs/proto/Cargo.toml
index e68616b..d0e4de7 100644
--- a/examples/message_passing_interface-rs/proto/Cargo.toml
+++ b/examples/message_passing_interface-rs/proto/Cargo.toml
@@ -25,8 +25,6 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
+num_enum = { version = "0.7.3", default-features = false }
 serde = { version = "1.0", features = ["derive"] }
 serde_json = "1.0"
-
-[build-dependencies]
-uuid = { version = "1.8", default-features = false }
diff --git a/examples/message_passing_interface-rs/proto/build.rs 
b/examples/message_passing_interface-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/message_passing_interface-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/message_passing_interface-rs/proto/src/lib.rs 
b/examples/message_passing_interface-rs/proto/src/lib.rs
index 7c99bdb..9ff156d 100644
--- a/examples/message_passing_interface-rs/proto/src/lib.rs
+++ b/examples/message_passing_interface-rs/proto/src/lib.rs
@@ -15,13 +15,16 @@
 // specific language governing permissions and limitations
 // under the License.
 
+use num_enum::FromPrimitive;
 use serde::{Serialize, Deserialize};
 pub use serde_json;
 
-#[derive(Serialize, Deserialize, Debug, Copy, Clone)]
+#[derive(Serialize, Deserialize, FromPrimitive, Debug, Copy, Clone)]
+#[repr(u32)]
 pub enum Command {
     Hello,
     Bye,
+    #[default]
     Unknown,
 }
 
@@ -36,16 +39,7 @@ pub struct EnclaveOutput {
     pub message: String
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::Hello,
-            1 => Command::Bye,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/message_passing_interface-rs/uuid.txt 
b/examples/message_passing_interface-rs/uuid.txt
index dc15e03..a455e97 100644
--- a/examples/message_passing_interface-rs/uuid.txt
+++ b/examples/message_passing_interface-rs/uuid.txt
@@ -1 +1 @@
-17556a46-bdab-11eb-b325-d38c9a9af725
+17556a46-bdab-11eb-b325-d38c9a9af725
\ No newline at end of file
diff --git a/examples/random-rs/proto/Cargo.toml 
b/examples/random-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/random-rs/proto/Cargo.toml
+++ b/examples/random-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/random-rs/proto/build.rs 
b/examples/random-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/random-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/random-rs/proto/src/lib.rs 
b/examples/random-rs/proto/src/lib.rs
index aaca807..1574077 100644
--- a/examples/random-rs/proto/src/lib.rs
+++ b/examples/random-rs/proto/src/lib.rs
@@ -16,20 +16,17 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     RandomGenerator,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::RandomGenerator,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/random-rs/uuid.txt b/examples/random-rs/uuid.txt
index 6c33def..39776a0 100644
--- a/examples/random-rs/uuid.txt
+++ b/examples/random-rs/uuid.txt
@@ -1 +1 @@
-197c710c-bdab-11eb-8f3f-17a5f698d23b
+197c710c-bdab-11eb-8f3f-17a5f698d23b
\ No newline at end of file
diff --git a/examples/secure_storage-rs/proto/Cargo.toml 
b/examples/secure_storage-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/secure_storage-rs/proto/Cargo.toml
+++ b/examples/secure_storage-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/secure_storage-rs/proto/build.rs 
b/examples/secure_storage-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/secure_storage-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/secure_storage-rs/proto/src/lib.rs 
b/examples/secure_storage-rs/proto/src/lib.rs
index c3f57a8..20eca8b 100644
--- a/examples/secure_storage-rs/proto/src/lib.rs
+++ b/examples/secure_storage-rs/proto/src/lib.rs
@@ -16,24 +16,19 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     Read,
     Write,
     Delete,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::Read,
-            1 => Command::Write,
-            2 => Command::Delete,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/secure_storage-rs/uuid.txt 
b/examples/secure_storage-rs/uuid.txt
index 745fccb..6a20bc4 100644
--- a/examples/secure_storage-rs/uuid.txt
+++ b/examples/secure_storage-rs/uuid.txt
@@ -1 +1 @@
-1cd6d392-bdab-11eb-9082-abc902ac5cd4
+1cd6d392-bdab-11eb-9082-abc902ac5cd4
\ No newline at end of file
diff --git a/examples/serde-rs/proto/Cargo.toml 
b/examples/serde-rs/proto/Cargo.toml
index 4aa0d53..91066a3 100644
--- a/examples/serde-rs/proto/Cargo.toml
+++ b/examples/serde-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build-dependencies]
-uuid = { version = "1.8", default-features = false }
\ No newline at end of file
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/serde-rs/proto/build.rs b/examples/serde-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/serde-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/serde-rs/proto/src/lib.rs 
b/examples/serde-rs/proto/src/lib.rs
index e21f550..97fe9f5 100644
--- a/examples/serde-rs/proto/src/lib.rs
+++ b/examples/serde-rs/proto/src/lib.rs
@@ -15,19 +15,17 @@
 // specific language governing permissions and limitations
 // under the License.
 
+use num_enum::{FromPrimitive, IntoPrimitive};
+
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     DefaultOp,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::DefaultOp,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/serde-rs/uuid.txt b/examples/serde-rs/uuid.txt
index 3767c5d..f4e878a 100644
--- a/examples/serde-rs/uuid.txt
+++ b/examples/serde-rs/uuid.txt
@@ -1 +1 @@
-1ed47816-bdab-11eb-9ebd-3ffe0648da93
+1ed47816-bdab-11eb-9ebd-3ffe0648da93
\ No newline at end of file
diff --git a/examples/signature_verification-rs/proto/Cargo.toml 
b/examples/signature_verification-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/signature_verification-rs/proto/Cargo.toml
+++ b/examples/signature_verification-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/signature_verification-rs/proto/build.rs 
b/examples/signature_verification-rs/proto/build.rs
deleted file mode 100644
index 778819a..0000000
--- a/examples/signature_verification-rs/proto/build.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::env;
-use std::fs;
-use std::fs::File;
-use std::io::Write;
-use std::path::PathBuf;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => u.trim().to_string(),
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/signature_verification-rs/proto/src/lib.rs 
b/examples/signature_verification-rs/proto/src/lib.rs
index ae239a5..e4bbb48 100644
--- a/examples/signature_verification-rs/proto/src/lib.rs
+++ b/examples/signature_verification-rs/proto/src/lib.rs
@@ -16,22 +16,18 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     Sign,
     Verify,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::Sign,
-            1 => Command::Verify,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/signature_verification-rs/uuid.txt 
b/examples/signature_verification-rs/uuid.txt
index cc340c8..7fc436c 100644
--- a/examples/signature_verification-rs/uuid.txt
+++ b/examples/signature_verification-rs/uuid.txt
@@ -1 +1 @@
-c7e478c2-89b3-46eb-ac19-571e66c3830d
+c7e478c2-89b3-46eb-ac19-571e66c3830d
\ No newline at end of file
diff --git a/examples/supp_plugin-rs/plugin_uuid.txt 
b/examples/supp_plugin-rs/plugin_uuid.txt
index e9fb431..9b4f37a 100644
--- a/examples/supp_plugin-rs/plugin_uuid.txt
+++ b/examples/supp_plugin-rs/plugin_uuid.txt
@@ -1 +1 @@
-ef620757-fa2b-4f19-a1c4-6e51cfe4c0f9
+ef620757-fa2b-4f19-a1c4-6e51cfe4c0f9
\ No newline at end of file
diff --git a/examples/supp_plugin-rs/proto/Cargo.toml 
b/examples/supp_plugin-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/supp_plugin-rs/proto/Cargo.toml
+++ b/examples/supp_plugin-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/supp_plugin-rs/proto/build.rs 
b/examples/supp_plugin-rs/proto/build.rs
deleted file mode 100644
index f18ed09..0000000
--- a/examples/supp_plugin-rs/proto/build.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    //ta uuid
-    let uuid = match fs::read_to_string("../ta_uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find ta_uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("ta_uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-
-    //plugin uuid
-    let uuid = match fs::read_to_string("../plugin_uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find plugin_uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("plugin_uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/supp_plugin-rs/proto/src/lib.rs 
b/examples/supp_plugin-rs/proto/src/lib.rs
index cc1f84e..1ac2e2d 100644
--- a/examples/supp_plugin-rs/proto/src/lib.rs
+++ b/examples/supp_plugin-rs/proto/src/lib.rs
@@ -16,40 +16,32 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     Ping,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::Ping,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const TA_UUID: &str = &include_str!(concat!(env!("OUT_DIR"), 
"/ta_uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 ta_uuid.txt`.
+pub const TA_UUID: &str = &include_str!("../../ta_uuid.txt");
 
 //for plugin
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum PluginCommand {
     Print,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for PluginCommand {
-    #[inline]
-    fn from(value: u32) -> PluginCommand {
-        match value {
-            0 => PluginCommand::Print,
-            _ => PluginCommand::Unknown,
-        }
-    }
-}
-
 pub const PLUGIN_SUBCMD_NULL: u32 = 0xFFFFFFFF;
-pub const PLUGIN_UUID: &str = &include_str!(concat!(env!("OUT_DIR"), 
"/plugin_uuid.txt"));
-
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 plugin_uuid.txt`.
+pub const PLUGIN_UUID: &str = &include_str!("../../plugin_uuid.txt");
diff --git a/examples/supp_plugin-rs/ta_uuid.txt 
b/examples/supp_plugin-rs/ta_uuid.txt
index e5411d8..3665046 100644
--- a/examples/supp_plugin-rs/ta_uuid.txt
+++ b/examples/supp_plugin-rs/ta_uuid.txt
@@ -1 +1 @@
-255fc838-de89-42d3-9a8e-d044c50fa57c
+255fc838-de89-42d3-9a8e-d044c50fa57c
\ No newline at end of file
diff --git a/examples/tcp_client-rs/proto/Cargo.toml 
b/examples/tcp_client-rs/proto/Cargo.toml
index b766f82..91066a3 100644
--- a/examples/tcp_client-rs/proto/Cargo.toml
+++ b/examples/tcp_client-rs/proto/Cargo.toml
@@ -26,6 +26,3 @@ edition = "2018"
 
 [dependencies]
 num_enum = { version = "0.7.3", default-features = false }
-
-[build-dependencies]
-uuid = { version = "1.8", default-features = false }
diff --git a/examples/tcp_client-rs/proto/build.rs 
b/examples/tcp_client-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/tcp_client-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/tcp_client-rs/proto/src/lib.rs 
b/examples/tcp_client-rs/proto/src/lib.rs
index 9034643..d5d0a2b 100644
--- a/examples/tcp_client-rs/proto/src/lib.rs
+++ b/examples/tcp_client-rs/proto/src/lib.rs
@@ -32,4 +32,7 @@ pub enum IpVersion {
     V6 = 2,
 }
 
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/tcp_client-rs/uuid.txt b/examples/tcp_client-rs/uuid.txt
index 386e8ab..43c8d01 100644
--- a/examples/tcp_client-rs/uuid.txt
+++ b/examples/tcp_client-rs/uuid.txt
@@ -1 +1 @@
-59db8536-e5e6-11eb-8e9b-a316ce7a6568
+59db8536-e5e6-11eb-8e9b-a316ce7a6568
\ No newline at end of file
diff --git a/examples/time-rs/proto/Cargo.toml 
b/examples/time-rs/proto/Cargo.toml
index c650c5b..91066a3 100644
--- a/examples/time-rs/proto/Cargo.toml
+++ b/examples/time-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build_dependencies]
-uuid = { version = "1.6.1", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/time-rs/proto/build.rs b/examples/time-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/time-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/time-rs/proto/src/lib.rs 
b/examples/time-rs/proto/src/lib.rs
index 006feea..2508b8e 100644
--- a/examples/time-rs/proto/src/lib.rs
+++ b/examples/time-rs/proto/src/lib.rs
@@ -16,20 +16,17 @@
 // under the License.
 
 #![no_std]
+use num_enum::{FromPrimitive, IntoPrimitive};
 
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     Test,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::Test,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/time-rs/uuid.txt b/examples/time-rs/uuid.txt
index 762fee6..3ca6db5 100644
--- a/examples/time-rs/uuid.txt
+++ b/examples/time-rs/uuid.txt
@@ -1 +1 @@
-21b1a1da-bdab-11eb-b614-275a7098826f
+21b1a1da-bdab-11eb-b614-275a7098826f
\ No newline at end of file
diff --git a/examples/tls_client-rs/proto/Cargo.toml 
b/examples/tls_client-rs/proto/Cargo.toml
index 10d7f5a..91066a3 100644
--- a/examples/tls_client-rs/proto/Cargo.toml
+++ b/examples/tls_client-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build-dependencies]
-uuid = { version = "1.8", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/tls_client-rs/proto/build.rs 
b/examples/tls_client-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/tls_client-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/tls_client-rs/proto/src/lib.rs 
b/examples/tls_client-rs/proto/src/lib.rs
index 7679b2d..4297873 100644
--- a/examples/tls_client-rs/proto/src/lib.rs
+++ b/examples/tls_client-rs/proto/src/lib.rs
@@ -15,19 +15,17 @@
 // specific language governing permissions and limitations
 // under the License.
 
+use num_enum::{FromPrimitive, IntoPrimitive};
+
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     Start,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::Start,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/tls_client-rs/uuid.txt b/examples/tls_client-rs/uuid.txt
index b4a8678..ba279ad 100644
--- a/examples/tls_client-rs/uuid.txt
+++ b/examples/tls_client-rs/uuid.txt
@@ -1 +1 @@
-ec55bfe2-d9c7-11eb-8b0e-f3f8fad927f7
+ec55bfe2-d9c7-11eb-8b0e-f3f8fad927f7
\ No newline at end of file
diff --git a/examples/tls_server-rs/proto/Cargo.toml 
b/examples/tls_server-rs/proto/Cargo.toml
index 10d7f5a..91066a3 100644
--- a/examples/tls_server-rs/proto/Cargo.toml
+++ b/examples/tls_server-rs/proto/Cargo.toml
@@ -25,6 +25,4 @@ description = "Data structures and functions shared by host 
and TA."
 edition = "2018"
 
 [dependencies]
-
-[build-dependencies]
-uuid = { version = "1.8", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/examples/tls_server-rs/proto/build.rs 
b/examples/tls_server-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/tls_server-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/tls_server-rs/proto/src/lib.rs 
b/examples/tls_server-rs/proto/src/lib.rs
index 7f71a24..0789019 100644
--- a/examples/tls_server-rs/proto/src/lib.rs
+++ b/examples/tls_server-rs/proto/src/lib.rs
@@ -15,25 +15,20 @@
 // specific language governing permissions and limitations
 // under the License.
 
+use num_enum::{FromPrimitive, IntoPrimitive};
+
+#[derive(FromPrimitive, IntoPrimitive)]
+#[repr(u32)]
 pub enum Command {
     NewTlsSession,
     CloseTlsSession,
     DoTlsRead,
     DoTlsWrite,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::NewTlsSession,
-            1 => Command::CloseTlsSession,
-            2 => Command::DoTlsRead,
-            3 => Command::DoTlsWrite,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/tls_server-rs/uuid.txt b/examples/tls_server-rs/uuid.txt
index d12f3ea..53f20f0 100644
--- a/examples/tls_server-rs/uuid.txt
+++ b/examples/tls_server-rs/uuid.txt
@@ -1 +1 @@
-69547de6-f47e-11eb-994e-f34e88d5c2b4
+69547de6-f47e-11eb-994e-f34e88d5c2b4
\ No newline at end of file
diff --git a/examples/udp_socket-rs/proto/Cargo.toml 
b/examples/udp_socket-rs/proto/Cargo.toml
index b766f82..91066a3 100644
--- a/examples/udp_socket-rs/proto/Cargo.toml
+++ b/examples/udp_socket-rs/proto/Cargo.toml
@@ -26,6 +26,3 @@ edition = "2018"
 
 [dependencies]
 num_enum = { version = "0.7.3", default-features = false }
-
-[build-dependencies]
-uuid = { version = "1.8", default-features = false }
diff --git a/examples/udp_socket-rs/proto/build.rs 
b/examples/udp_socket-rs/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/examples/udp_socket-rs/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/examples/udp_socket-rs/proto/src/lib.rs 
b/examples/udp_socket-rs/proto/src/lib.rs
index 88fa36b..9918e17 100644
--- a/examples/udp_socket-rs/proto/src/lib.rs
+++ b/examples/udp_socket-rs/proto/src/lib.rs
@@ -32,4 +32,7 @@ pub enum IpVersion {
     V6 = 2,
 }
 
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/examples/udp_socket-rs/uuid.txt b/examples/udp_socket-rs/uuid.txt
index e91b72f..b6c1c19 100644
--- a/examples/udp_socket-rs/uuid.txt
+++ b/examples/udp_socket-rs/uuid.txt
@@ -1 +1 @@
-87c2d78e-eb7b-11eb-8d25-df4d5338f285
+87c2d78e-eb7b-11eb-8d25-df4d5338f285
\ No newline at end of file
diff --git a/projects/web3/eth_wallet/proto/Cargo.toml 
b/projects/web3/eth_wallet/proto/Cargo.toml
index 5e710ee..d787a60 100644
--- a/projects/web3/eth_wallet/proto/Cargo.toml
+++ b/projects/web3/eth_wallet/proto/Cargo.toml
@@ -27,6 +27,4 @@ edition = "2018"
 [dependencies]
 uuid = { version = "1.8", features = ["serde"] }
 serde = { version = "1.0", features = ["derive"] }
-
-[build-dependencies]
-uuid = { version = "1.8", default-features = false }
+num_enum = { version = "0.7.3", default-features = false }
diff --git a/projects/web3/eth_wallet/proto/build.rs 
b/projects/web3/eth_wallet/proto/build.rs
deleted file mode 100644
index b9d0612..0000000
--- a/projects/web3/eth_wallet/proto/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::fs;
-use std::path::PathBuf;
-use std::fs::File;
-use std::env;
-use std::io::Write;
-
-fn main() {
-    let uuid = match fs::read_to_string("../uuid.txt") {
-        Ok(u) => {
-            u.trim().to_string()
-        },
-        Err(_) => {
-            panic!("Cannot find uuid.txt");
-        }
-    };
-    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
-    let mut buffer = File::create(out.join("uuid.txt")).unwrap();
-    write!(buffer, "{}", uuid).unwrap();
-}
diff --git a/projects/web3/eth_wallet/proto/src/lib.rs 
b/projects/web3/eth_wallet/proto/src/lib.rs
index 87c42bb..88393c1 100644
--- a/projects/web3/eth_wallet/proto/src/lib.rs
+++ b/projects/web3/eth_wallet/proto/src/lib.rs
@@ -15,29 +15,24 @@
 // specific language governing permissions and limitations
 // under the License.
 
+use num_enum::{FromPrimitive, IntoPrimitive};
+
 mod in_out;
 pub use in_out::*;
 
-#[derive(Debug)]
+
+#[derive(FromPrimitive, IntoPrimitive, Debug)]
+#[repr(u32)]
 pub enum Command {
     CreateWallet,
     RemoveWallet,
     DeriveAddress,
     SignTransaction,
+    #[default]
     Unknown,
 }
 
-impl From<u32> for Command {
-    #[inline]
-    fn from(value: u32) -> Command {
-        match value {
-            0 => Command::CreateWallet,
-            1 => Command::RemoveWallet,
-            2 => Command::DeriveAddress,
-            3 => Command::SignTransaction,
-            _ => Command::Unknown,
-        }
-    }
-}
-
-pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
+// If Uuid::parse_str() returns an InvalidLength error, there may be an extra
+// newline in your uuid.txt file. You can remove it by running 
+// `truncate -s 36 uuid.txt`.
+pub const UUID: &str = &include_str!("../../uuid.txt");
diff --git a/projects/web3/eth_wallet/uuid.txt 
b/projects/web3/eth_wallet/uuid.txt
index c0c0f3f..d0d0843 100644
--- a/projects/web3/eth_wallet/uuid.txt
+++ b/projects/web3/eth_wallet/uuid.txt
@@ -1 +1 @@
-be2dc9a0-02b4-4b33-ba21-9964dbdf1573
+be2dc9a0-02b4-4b33-ba21-9964dbdf1573
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to