ivila commented on code in PR #178:
URL: 
https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/178#discussion_r2034520603


##########
optee-utee/src/ta_session.rs:
##########
@@ -0,0 +1,150 @@
+// 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 core::ptr;
+use optee_utee_sys as raw;
+
+use crate::{Error, Result, TeeParams, Uuid};
+
+/// Represents a connection between a trusted application and another trusted 
application (can be user TA or pseudo TA).
+pub struct TaSession {
+    raw: raw::TEE_TASessionHandle,
+    target_uuid: Uuid,
+    default_timeout: u32,
+}
+
+impl TaSession {
+    /// Start configuring a new TA session with infinite timeout by default.
+    pub fn new(uuid: Uuid) -> Self {
+        Self {
+            raw: core::ptr::null_mut(),
+            target_uuid: uuid,
+            default_timeout: raw::TEE_TIMEOUT_INFINITE,
+        }
+    }
+
+    /// Set the default timeout for this session.
+    /// Can be called both before and after opening the session.
+    pub fn timeout(mut self, timeout: u32) -> Self {
+        self.default_timeout = timeout;
+        self
+    }
+
+    /// Set the default timeout for this session (mutable version).
+    /// Returns self to allow method chaining with invoke().
+    pub fn with_timeout(&mut self, timeout: u32) -> &mut Self {
+        self.default_timeout = timeout;
+        self
+    }
+
+    /// Open the session without parameters.
+    pub fn open(mut self) -> Result<Self> {

Review Comment:
   Maybe consider introducing a `TaSessionBuilder` struct? Mixing them together 
isn't very ergonomic.
   
   Also, maybe consider supporting timeout configuration in `TeeParams`. That 
way, developers can use `open_with_params` to set the timeout, and we wouldn't 
need a separate timeout argument for `open`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org
For additional commands, e-mail: dev-h...@teaclave.apache.org

Reply via email to