Skip to content
This repository was archived by the owner on May 9, 2022. It is now read-only.

Commit 616e985

Browse files
committed
feat(rtc_types::enclave_messages::errors): make error types FFI-safe
1 parent 328887b commit 616e985

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

rtc_types/src/enclave_messages/errors.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use thiserror::Error;
1111
/// See: `rtc_tenclave::dh::sessions::DhSessions`
1212
#[derive(Debug, PartialEq)] // core
1313
#[derive(Error)] // thiserror
14+
#[repr(C)]
1415
pub enum AcquireSessionError {
1516
/// This should generally be treated as an unrecoverable error.
1617
#[error("Channel mutex poisoned")]
@@ -40,20 +41,22 @@ impl From<sgx_status_t> for AcquireSessionError {
4041

4142
#[derive(Debug)] // core
4243
#[derive(Error)] // thiserror
44+
#[repr(C)]
4345
pub enum SealingError {
4446
#[error("Failed to acquire ProtectedChannel: {0}")]
4547
ChannelNotFound(#[from] AcquireSessionError),
4648

47-
#[error("Failed to rkyv-serialize message: {0:?}")]
48-
RkyvSerializerFailed(BufferSerializerError),
49+
#[error("Failed to rkyv-serialize message (BufferSerializerError omitted)")]
50+
RkyvBufferSerializerError, // see impl From<BufferSerializerError>
4951

5052
#[error("SGX error: {0:?}")]
5153
Sgx(sgx_status_t),
5254
}
5355

56+
/// BufferSerializerError is not FFI-safe: ignore it, for now.
5457
impl From<BufferSerializerError> for SealingError {
55-
fn from(error: BufferSerializerError) -> Self {
56-
SealingError::RkyvSerializerFailed(error)
58+
fn from(_: BufferSerializerError) -> Self {
59+
SealingError::RkyvBufferSerializerError
5760
}
5861
}
5962

0 commit comments

Comments
 (0)