Skip to content

Commit

Permalink
Made most enums that correspond to cFE/OSAL parameters #[non_exhaustive]
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zec committed Jul 25, 2023
1 parent 36bb28a commit 2f7ef29
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 7 deletions.
5 changes: 4 additions & 1 deletion n2o4/src/cfe/es.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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")]
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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")]
Expand Down
3 changes: 2 additions & 1 deletion n2o4/src/cfe/evs.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -131,6 +131,7 @@ pub fn register<T: FilterScheme>(filters: &[T]) -> Result<EventSender, Status> {
#[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")]
Expand Down
3 changes: 2 additions & 1 deletion n2o4/src/cfe/msg.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -487,6 +487,7 @@ impl<T: Copy> DerefMut for Telemetry<T> {
#[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")]
Expand Down
4 changes: 3 additions & 1 deletion n2o4/src/cfe/sb.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -98,6 +98,7 @@ impl From<MsgId> 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")]
Expand All @@ -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")]
Expand Down
6 changes: 5 additions & 1 deletion n2o4/src/cfe/tbl.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -544,6 +544,7 @@ impl<T: TableType> Drop for SharedTblHandle<T> {

/// Alternative successful or partially-successful outcomes of [`TblHandle::register`].
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[non_exhaustive]
pub enum RegisterInfo {
/// Normal successful registration.
Normal,
Expand Down Expand Up @@ -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.
Expand All @@ -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.
///
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion n2o4/src/osal/file.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -197,6 +197,7 @@ impl From<OwnedFile> for File {
/// Used with [`File::open_create`].
#[repr(i32)]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[non_exhaustive]
pub enum AccessMode {
/// Read-only access.
///
Expand Down Expand Up @@ -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.
///
Expand Down
1 change: 1 addition & 0 deletions n2o4/src/osal/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ impl<D: SocketDomain, T: SocketType, R: SocketRole> PartialEq<Self> for Socket<D
#[doc(alias = "OS_SocketShutdownMode_t")]
#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(u32)]
#[non_exhaustive]
pub enum SocketShutdownMode {
/// Shut down the read direction of the session.
#[doc(alias = "OS_SocketShutdownMode_SHUT_READ")]
Expand Down
3 changes: 2 additions & 1 deletion n2o4/src/osal/sync.rs
Original file line number Diff line number Diff line change
@@ -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

//! Synchronization primitives.
Expand Down Expand Up @@ -171,6 +171,7 @@ impl TryFrom<ObjectId> 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,
Expand Down

0 comments on commit 2f7ef29

Please sign in to comment.