add some documentation
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2024-01-31 15:19:18 +01:00
parent 9759818d94
commit 9bea82ff0e
Signed by: muellerr
GPG Key ID: A649FB78196E3849
3 changed files with 22 additions and 8 deletions

View File

@ -123,4 +123,5 @@ doc-images = []
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true
rustdoc-args = ["--cfg", "doc_cfg"] targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = ["--cfg", "doc_cfg", "--generate-link-to-definition"]

View File

@ -194,6 +194,9 @@ pub trait EcssTcSenderCore: EcssChannel {
fn send_tc(&self, tc: PusTcCreator, token: Option<TcStateToken>) -> Result<(), EcssTmtcError>; fn send_tc(&self, tc: PusTcCreator, token: Option<TcStateToken>) -> Result<(), EcssTmtcError>;
} }
/// A PUS telecommand packet can be stored in memory using different methods. Right now,
/// storage inside a pool structure like [LocalPool], and storage inside a `Vec<u8>` are
/// supported.
#[non_exhaustive] #[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum TcInMemory { pub enum TcInMemory {
@ -215,6 +218,7 @@ impl From<alloc::vec::Vec<u8>> for TcInMemory {
} }
} }
/// Generic structure for an ECSS PUS Telecommand and its correspoding verification token.
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct EcssTcAndToken { pub struct EcssTcAndToken {
pub tc_in_memory: TcInMemory, pub tc_in_memory: TcInMemory,
@ -363,6 +367,7 @@ mod alloc_mod {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
pub mod std_mod { pub mod std_mod {
use crate::pool::{SharedPool, StoreAddr}; use crate::pool::{SharedPool, StoreAddr};
use crate::pus::verification::{ use crate::pus::verification::{
@ -705,7 +710,7 @@ pub mod std_mod {
} }
} }
/// Converter structure for PUS telecommands which are stored inside a [Vec<u8>] structure. /// Converter structure for PUS telecommands which are stored inside a `Vec<u8>` structure.
/// Please note that this structure is not able to convert TCs which are stored inside a /// Please note that this structure is not able to convert TCs which are stored inside a
/// [SharedPool]. /// [SharedPool].
pub struct EcssTcInVecConverter { pub struct EcssTcInVecConverter {
@ -827,12 +832,13 @@ pub mod std_mod {
} }
} }
/// Base class for handlers which can handle PUS TC packets. Right now, the verification /// This is a high-level PUS packet handler. It performs some of the boilerplate acitivities
/// reporter is constrained to the [StdVerifReporterWithSender] and the service handler /// involved when handling PUS telecommands and it can be used to implement the handling of
/// relies on TMTC packets being exchanged via a [SharedPool]. Please note that this variant /// PUS telecommands for certain PUS telecommands groups (for example individual services).
/// of the PUS service base is not optimized for handling packets sent as a `Vec<u8>` and ///
/// might perform additional copies to the internal buffer as well. The class should /// This base class can handle PUS telecommands backed by different memory storage machanisms
/// still behave correctly. /// by using the [EcssTcInMemConverter] abstraction. This object provides some convenience
/// methods to make the generic parts of TC handling easier.
pub struct PusServiceHandler<TcInMemConverter: EcssTcInMemConverter> { pub struct PusServiceHandler<TcInMemConverter: EcssTcInMemConverter> {
pub common: PusServiceBase, pub common: PusServiceBase,
pub tc_in_mem_converter: TcInMemConverter, pub tc_in_mem_converter: TcInMemConverter,
@ -857,6 +863,11 @@ pub mod std_mod {
} }
} }
/// This function can be used to poll the internal [EcssTcReceiver] object for the next
/// telecommand packet. It will return `Ok(None)` if there are not packets available.
/// In any other case, it will perform the acceptance of the ECSS TC packet using the
/// internal [VerificationReporterWithSender] object. It will then return the telecommand
/// and the according accepted token.
pub fn retrieve_and_accept_next_packet( pub fn retrieve_and_accept_next_packet(
&mut self, &mut self,
) -> Result<Option<AcceptedEcssTcAndToken>, PusPacketHandlingError> { ) -> Result<Option<AcceptedEcssTcAndToken>, PusPacketHandlingError> {

View File

@ -208,6 +208,8 @@ impl WasAtLeastAccepted for TcStateAccepted {}
impl WasAtLeastAccepted for TcStateStarted {} impl WasAtLeastAccepted for TcStateStarted {}
impl WasAtLeastAccepted for TcStateCompleted {} impl WasAtLeastAccepted for TcStateCompleted {}
/// Token wrapper to model all possible verification tokens. These tokens are used to
/// enforce the correct order for the verification steps when doing verification reporting.
#[derive(Debug, Copy, Clone, Eq, PartialEq)] #[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum TcStateToken { pub enum TcStateToken {
None(VerificationToken<TcStateNone>), None(VerificationToken<TcStateNone>),