From 2f7ef29ef4f8d285ea7a02ee9add1b755a01abc6 Mon Sep 17 00:00:00 2001 From: Zachary Catlin Date: Mon, 24 Jul 2023 21:22:21 -0400 Subject: [PATCH] Made most enums that correspond to cFE/OSAL parameters #[non_exhaustive] Our crate doesn't get to control whether more variants of these get added to the API surface, so #[non_exhaustive] is more accurate. This doesn't really affect us now, but could come in useful should n2o4 become more generally used. --- n2o4/src/cfe/es.rs | 5 ++++- n2o4/src/cfe/evs.rs | 3 ++- n2o4/src/cfe/msg.rs | 3 ++- n2o4/src/cfe/sb.rs | 4 +++- n2o4/src/cfe/tbl.rs | 6 +++++- n2o4/src/osal/file.rs | 4 +++- n2o4/src/osal/socket.rs | 1 + n2o4/src/osal/sync.rs | 3 ++- 8 files changed, 22 insertions(+), 7 deletions(-) diff --git a/n2o4/src/cfe/es.rs b/n2o4/src/cfe/es.rs index 54798fe1..cd7f728a 100644 --- a/n2o4/src/cfe/es.rs +++ b/n2o4/src/cfe/es.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2022 The Pennsylvania State University and the project contributors. +// Copyright (c) 2021-2023 The Pennsylvania State University and the project contributors. // SPDX-License-Identifier: Apache-2.0 //! Executive Services system. @@ -13,6 +13,7 @@ use printf_wrap::{PrintfArgument, PrintfFmt}; #[doc(alias = "CFE_ES_RunStatus")] #[derive(Clone, Copy, PartialEq, Eq, Debug)] #[repr(u32)] +#[non_exhaustive] pub enum RunStatus { /// Application is exiting with an error. #[doc(alias = "CFE_ES_RunStatus_APP_ERROR")] @@ -59,6 +60,7 @@ pub enum RunStatus { #[doc(alias = "CFE_ES_SystemState")] #[derive(Clone, Copy, PartialEq, Eq, Debug)] #[repr(u32)] +#[non_exhaustive] pub enum SystemState { /// Single-threaded mode while setting up CFE itself. #[doc(alias = "CFE_ES_SystemState_EARLY_INIT")] @@ -88,6 +90,7 @@ pub enum SystemState { /// The type of cFE system reset desired in a call to [`reset_cfe`]. #[derive(Clone, Copy, PartialEq, Eq, Debug)] #[repr(u32)] +#[non_exhaustive] pub enum ResetType { /// A reset that causes all memory to be cleared. #[doc(alias = "CFE_PSP_RST_TYPE_POWERON")] diff --git a/n2o4/src/cfe/evs.rs b/n2o4/src/cfe/evs.rs index 9f5ab233..a791fc97 100644 --- a/n2o4/src/cfe/evs.rs +++ b/n2o4/src/cfe/evs.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2022 The Pennsylvania State University and the project contributors. +// Copyright (c) 2021-2023 The Pennsylvania State University and the project contributors. // SPDX-License-Identifier: Apache-2.0 //! Event system. @@ -131,6 +131,7 @@ pub fn register(filters: &[T]) -> Result { #[doc(alias = "CFE_EVS_EventType")] #[derive(Clone, Copy, PartialEq, Eq, Debug)] #[repr(u16)] +#[non_exhaustive] pub enum EventType { /// Events that are intended only for debugging, not nominal operations. #[doc(alias = "CFE_EVS_EventType_DEBUG")] diff --git a/n2o4/src/cfe/msg.rs b/n2o4/src/cfe/msg.rs index a82bcd33..4e4d8c8d 100644 --- a/n2o4/src/cfe/msg.rs +++ b/n2o4/src/cfe/msg.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2022 The Pennsylvania State University and the project contributors. +// Copyright (c) 2021-2023 The Pennsylvania State University and the project contributors. // SPDX-License-Identifier: Apache-2.0 //! Message utilities. @@ -487,6 +487,7 @@ impl DerefMut for Telemetry { #[doc(alias = "CFG_MSG_Type")] #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[repr(u32)] +#[non_exhaustive] pub enum MsgType { /// Command message. #[doc(alias = "CFG_MSG_Type_Cmd")] diff --git a/n2o4/src/cfe/sb.rs b/n2o4/src/cfe/sb.rs index e3f12fdd..193835f5 100644 --- a/n2o4/src/cfe/sb.rs +++ b/n2o4/src/cfe/sb.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2022 The Pennsylvania State University and the project contributors. +// Copyright (c) 2021-2023 The Pennsylvania State University and the project contributors. // SPDX-License-Identifier: Apache-2.0 //! Software Bus system. @@ -98,6 +98,7 @@ impl From for MsgId_Atom { #[doc(alias = "CFG_SB_QosPriority")] #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[repr(u8)] +#[non_exhaustive] pub enum QosPriority { /// High priority. #[doc(alias = "CFG_SB_QosPriority_HIGH")] @@ -112,6 +113,7 @@ pub enum QosPriority { #[doc(alias = "CFG_SB_QosReliability")] #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[repr(u8)] +#[non_exhaustive] pub enum QosReliability { /// High reliability. #[doc(alias = "CFG_SB_QosReliability_HIGH")] diff --git a/n2o4/src/cfe/tbl.rs b/n2o4/src/cfe/tbl.rs index 92b88ff2..059c8cbb 100644 --- a/n2o4/src/cfe/tbl.rs +++ b/n2o4/src/cfe/tbl.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2022 The Pennsylvania State University and the project contributors. +// Copyright (c) 2021-2023 The Pennsylvania State University and the project contributors. // SPDX-License-Identifier: Apache-2.0 //! Table system. @@ -544,6 +544,7 @@ impl Drop for SharedTblHandle { /// Alternative successful or partially-successful outcomes of [`TblHandle::register`]. #[derive(Clone, Copy, PartialEq, Eq, Debug)] +#[non_exhaustive] pub enum RegisterInfo { /// Normal successful registration. Normal, @@ -582,6 +583,7 @@ impl Default for TblOptions { /// Options regarding buffer use on table modifications. #[derive(Clone, Copy, PartialEq, Eq, Debug)] #[repr(u16)] +#[non_exhaustive] pub enum TblBuffering { /// Modifications to the table will use a shared memory space, /// copying to the actual table buffer when the table update occurs. @@ -608,6 +610,7 @@ pub enum TblBuffering { /// stored in the Critical Data Store (CDS). #[derive(Clone, Copy, PartialEq, Eq, Debug)] #[repr(u16)] +#[non_exhaustive] pub enum TblCriticality { /// Not critical; no copy of the table will be stored in the CDS. /// @@ -635,6 +638,7 @@ pub enum TblLoadSource<'a, T> { /// A pending action for a table. #[derive(Clone, Copy, Debug)] +#[non_exhaustive] pub enum PendingAction { /// An update is pending. Update, diff --git a/n2o4/src/osal/file.rs b/n2o4/src/osal/file.rs index 16f8a460..36e3e681 100644 --- a/n2o4/src/osal/file.rs +++ b/n2o4/src/osal/file.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2022 The Pennsylvania State University and the project contributors. +// Copyright (c) 2022-2023 The Pennsylvania State University and the project contributors. // SPDX-License-Identifier: Apache-2.0 //! Types and methods for interacting with files. @@ -197,6 +197,7 @@ impl From for File { /// Used with [`File::open_create`]. #[repr(i32)] #[derive(Clone, Copy, PartialEq, Eq, Debug)] +#[non_exhaustive] pub enum AccessMode { /// Read-only access. /// @@ -275,6 +276,7 @@ impl BitOrAssign for FileFlags { /// Used as the `whence` argument of [`File::lseek`]. #[repr(u32)] #[derive(Clone, Copy, PartialEq, Eq, Debug)] +#[non_exhaustive] pub enum SeekReference { /// Seek from the beginning of the file. /// diff --git a/n2o4/src/osal/socket.rs b/n2o4/src/osal/socket.rs index 6c4f15f6..cc41498a 100644 --- a/n2o4/src/osal/socket.rs +++ b/n2o4/src/osal/socket.rs @@ -695,6 +695,7 @@ impl PartialEq for Socket for BinSem { /// The initial state of a semaphore. #[repr(u32)] #[derive(Clone, Copy, PartialEq, Eq, Debug)] +#[non_exhaustive] pub enum BinSemState { /// Full state. Full = OS_SEM_FULL,