doc cfg support

This commit is contained in:
Robin Müller 2022-10-26 00:23:10 +02:00
parent 18a3be8439
commit 4b5b11486e
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
7 changed files with 53 additions and 12 deletions

View File

@ -42,3 +42,7 @@ default = ["std"]
std = ["downcast-rs/std", "alloc", "bus", "postcard/use-std", "crossbeam-channel/std"] std = ["downcast-rs/std", "alloc", "bus", "postcard/use-std", "crossbeam-channel/std"]
alloc = [] alloc = []
heapless = [] heapless = []
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "doc_cfg"]

View File

@ -1,4 +1,4 @@
//! [Event][crate::events::Event] management and forwarding //! Event management and forwarding
use crate::events::{EventU16TypedSev, EventU32, GenericEvent, HasSeverity}; use crate::events::{EventU16TypedSev, EventU32, GenericEvent, HasSeverity};
use alloc::boxed::Box; use alloc::boxed::Box;
use alloc::vec; use alloc::vec;

View File

@ -1,5 +1,32 @@
//! Event support module //! Event support module
//!
//! This module includes the basic event structs [EventU32] and [EventU16] and versions with the
//! ECSS severity levels as a type parameter. These structs are simple abstractions on top of the
//! [u32] and [u16] types where the raw value is the unique identifier for a particular event.
//! The abstraction also allows to group related events using a group ID, and the severity
//! of an event is encoded inside the raw value itself with four possible [Severity] levels:
//!
//! - INFO
//! - LOW
//! - MEDIUM
//! - HIGH
//!
//! All event structs implement the [EcssEnumeration] trait and can be created as constants.
//! This allows to easily create a static list of constant events which can then be used to generate
//! event telemetry using the PUS event manager modules.
//!
//! # Examples
//!
//! ```
//! use fsrc_core::events::{EventU16, EventU32, EventU32TypedSev, Severity, SeverityHigh, SeverityInfo};
//!
//! const MSG_RECVD: EventU32TypedSev<SeverityInfo> = EventU32TypedSev::const_new(1, 0);
//! const MSG_FAILED: EventU32 = EventU32::const_new(Severity::LOW, 1, 1);
//!
//! const TEMPERATURE_HIGH: EventU32TypedSev<SeverityHigh> = EventU32TypedSev::const_new(2, 0);
//!
//! let small_event = EventU16::new(Severity::INFO, 3, 0);
//! ```
use core::hash::Hash; use core::hash::Hash;
use delegate::delegate; use delegate::delegate;
use spacepackets::ecss::{EcssEnumeration, ToBeBytes}; use spacepackets::ecss::{EcssEnumeration, ToBeBytes};
@ -23,24 +50,28 @@ pub trait HasSeverity {
const SEVERITY: Severity; const SEVERITY: Severity;
} }
/// Type level support struct
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub struct SeverityInfo {} pub struct SeverityInfo {}
impl HasSeverity for SeverityInfo { impl HasSeverity for SeverityInfo {
const SEVERITY: Severity = Severity::INFO; const SEVERITY: Severity = Severity::INFO;
} }
/// Type level support struct
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub struct SeverityLow {} pub struct SeverityLow {}
impl HasSeverity for SeverityLow { impl HasSeverity for SeverityLow {
const SEVERITY: Severity = Severity::LOW; const SEVERITY: Severity = Severity::LOW;
} }
/// Type level support struct
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub struct SeverityMedium {} pub struct SeverityMedium {}
impl HasSeverity for SeverityMedium { impl HasSeverity for SeverityMedium {
const SEVERITY: Severity = Severity::MEDIUM; const SEVERITY: Severity = Severity::MEDIUM;
} }
/// Type level support struct
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub struct SeverityHigh {} pub struct SeverityHigh {}
impl HasSeverity for SeverityHigh { impl HasSeverity for SeverityHigh {
@ -76,7 +107,7 @@ impl TryFrom<u8> for Severity {
} }
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct EventBase<RAW, GID, UID> { struct EventBase<RAW, GID, UID> {
severity: Severity, severity: Severity,
group_id: GID, group_id: GID,
unique_id: UID, unique_id: UID,
@ -322,7 +353,7 @@ impl<SEVERITY: HasSeverity> EventU32TypedSev<SEVERITY> {
}) })
} }
/// Const version of [new], but panics on invalid group ID input values. /// Const version of [Self::new], but panics on invalid group ID input values.
pub const fn const_new( pub const fn const_new(
group_id: <Self as GenericEvent>::GroupId, group_id: <Self as GenericEvent>::GroupId,
unique_id: <Self as GenericEvent>::UniqueId, unique_id: <Self as GenericEvent>::UniqueId,
@ -421,7 +452,7 @@ impl EventU16 {
}) })
} }
/// Const version of [new], but panics on invalid group ID input values. /// Const version of [Self::new], but panics on invalid group ID input values.
pub const fn const_new( pub const fn const_new(
severity: Severity, severity: Severity,
group_id: <Self as GenericEvent>::GroupId, group_id: <Self as GenericEvent>::GroupId,
@ -459,7 +490,7 @@ impl<SEVERITY: HasSeverity> EventU16TypedSev<SEVERITY> {
}) })
} }
/// Const version of [new], but panics on invalid group ID input values. /// Const version of [Self::new], but panics on invalid group ID input values.
pub const fn const_new( pub const fn const_new(
group_id: <Self as GenericEvent>::GroupId, group_id: <Self as GenericEvent>::GroupId,
unique_id: <Self as GenericEvent>::UniqueId, unique_id: <Self as GenericEvent>::UniqueId,

View File

@ -15,13 +15,16 @@ extern crate std;
pub mod error; pub mod error;
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
pub mod event_man; pub mod event_man;
pub mod events; pub mod events;
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
pub mod executable; pub mod executable;
pub mod hal; pub mod hal;
pub mod objects; pub mod objects;
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
pub mod pool; pub mod pool;
pub mod pus; pub mod pus;
pub mod tmtc; pub mod tmtc;

View File

@ -6,12 +6,14 @@ use hashbrown::HashSet;
use crate::pus::event::EventReporter; use crate::pus::event::EventReporter;
use crate::pus::{EcssTmError, EcssTmSender}; use crate::pus::{EcssTmError, EcssTmSender};
#[cfg(feature = "heapless")] #[cfg(feature = "heapless")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "heapless")))]
pub use heapless_mod::*; pub use heapless_mod::*;
/// This trait allows the PUS event manager implementation to stay generic over various types /// This trait allows the PUS event manager implementation to stay generic over various types
/// of backend containers. These backend containers keep track on whether a particular event /// of backend containers.
/// is enabled or disabled for reporting and also expose a simple API to enable or disable the event ///
/// reporting. /// These backend containers keep track on whether a particular event is enabled or disabled for
/// reporting and also expose a simple API to enable or disable the event reporting.
/// ///
/// For example, a straight forward implementation for host systems could use a /// For example, a straight forward implementation for host systems could use a
/// [hash set](https://docs.rs/hashbrown/latest/hashbrown/struct.HashSet.html) /// [hash set](https://docs.rs/hashbrown/latest/hashbrown/struct.HashSet.html)
@ -59,6 +61,7 @@ pub mod heapless_mod {
use crate::events::{GenericEvent, LargestEventRaw}; use crate::events::{GenericEvent, LargestEventRaw};
use std::marker::PhantomData; use std::marker::PhantomData;
#[cfg_attr(doc_cfg, doc(cfg(feature = "heapless")))]
// TODO: After a new version of heapless is released which uses hash32 version 0.3, try using // TODO: After a new version of heapless is released which uses hash32 version 0.3, try using
// regular Event type again. // regular Event type again.
#[derive(Default)] #[derive(Default)]

View File

@ -987,7 +987,7 @@ mod stdmod {
} }
/// Verification sender with a [mpsc::Sender] backend. /// Verification sender with a [mpsc::Sender] backend.
/// It implements the [VerificationSender] trait to be used as PUS Verification TM sender. /// It implements the [EcssTmSender] trait to be used as PUS Verification TM sender.
impl MpscVerifSender { impl MpscVerifSender {
pub fn new(tm_store: SharedPool, tx: mpsc::Sender<StoreAddr>) -> Self { pub fn new(tm_store: SharedPool, tx: mpsc::Sender<StoreAddr>) -> Self {
Self { Self {
@ -1014,7 +1014,7 @@ mod stdmod {
} }
/// Verification sender with a [crossbeam_channel::Sender] backend. /// Verification sender with a [crossbeam_channel::Sender] backend.
/// It implements the [VerificationSender] trait to be used as PUS Verification TM sender /// It implements the [EcssTmSender] trait to be used as PUS Verification TM sender
pub struct CrossbeamVerifSender { pub struct CrossbeamVerifSender {
base: StdSenderBase<crossbeam_channel::Sender<StoreAddr>>, base: StdSenderBase<crossbeam_channel::Sender<StoreAddr>>,
} }

@ -1 +1 @@
Subproject commit a2673c98707ecbbabb9535bef607025c92b54724 Subproject commit 65e85f20e03507f19a0d5086ee19360ff7596c27