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

Commit

Permalink
feat(rtc_types::enclave_messages::errors): make error types FFI-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
PiDelport committed Jun 21, 2021
1 parent 328887b commit 616e985
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions rtc_types/src/enclave_messages/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use thiserror::Error;
/// See: `rtc_tenclave::dh::sessions::DhSessions`
#[derive(Debug, PartialEq)] // core
#[derive(Error)] // thiserror
#[repr(C)]
pub enum AcquireSessionError {
/// This should generally be treated as an unrecoverable error.
#[error("Channel mutex poisoned")]
Expand Down Expand Up @@ -40,20 +41,22 @@ impl From<sgx_status_t> for AcquireSessionError {

#[derive(Debug)] // core
#[derive(Error)] // thiserror
#[repr(C)]
pub enum SealingError {
#[error("Failed to acquire ProtectedChannel: {0}")]
ChannelNotFound(#[from] AcquireSessionError),

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

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

/// BufferSerializerError is not FFI-safe: ignore it, for now.
impl From<BufferSerializerError> for SealingError {
fn from(error: BufferSerializerError) -> Self {
SealingError::RkyvSerializerFailed(error)
fn from(_: BufferSerializerError) -> Self {
SealingError::RkyvBufferSerializerError
}
}

Expand Down

0 comments on commit 616e985

Please sign in to comment.