doc fixes

This commit is contained in:
Robin Müller 2023-01-03 13:02:12 +01:00
parent 985dca351a
commit a952a8405f
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
9 changed files with 83 additions and 82 deletions

View File

@ -12,7 +12,7 @@ use std::vec::Vec;
/// be declared upfront. This avoids dynamic allocation during run-time. The user can specify a TC /// be declared upfront. This avoids dynamic allocation during run-time. The user can specify a TC
/// receiver in form of a special trait object which implements [ReceivesTc]. Please note that the /// receiver in form of a special trait object which implements [ReceivesTc]. Please note that the
/// receiver should copy out the received data if it the data is required past the /// receiver should copy out the received data if it the data is required past the
/// [ReceivesTc::pass_tc] call. /// [ReceivesTcCore::pass_tc] call.
/// ///
/// # Examples /// # Examples
/// ///

View File

@ -4,7 +4,7 @@ use spacepackets::tm::PusTm;
use spacepackets::tm::PusTmSecondaryHeader; use spacepackets::tm::PusTmSecondaryHeader;
use spacepackets::{SpHeader, MAX_APID}; use spacepackets::{SpHeader, MAX_APID};
use crate::pus::EcssTmSenderBase; use crate::pus::EcssTmSenderCore;
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
pub use allocvec::EventReporter; pub use allocvec::EventReporter;
@ -78,7 +78,7 @@ impl EventReporterBase {
pub fn event_info<E>( pub fn event_info<E>(
&mut self, &mut self,
buf: &mut [u8], buf: &mut [u8],
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
event_id: impl EcssEnumeration, event_id: impl EcssEnumeration,
aux_data: Option<&[u8]>, aux_data: Option<&[u8]>,
@ -96,7 +96,7 @@ impl EventReporterBase {
pub fn event_low_severity<E>( pub fn event_low_severity<E>(
&mut self, &mut self,
buf: &mut [u8], buf: &mut [u8],
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
event_id: impl EcssEnumeration, event_id: impl EcssEnumeration,
aux_data: Option<&[u8]>, aux_data: Option<&[u8]>,
@ -114,7 +114,7 @@ impl EventReporterBase {
pub fn event_medium_severity<E>( pub fn event_medium_severity<E>(
&mut self, &mut self,
buf: &mut [u8], buf: &mut [u8],
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
event_id: impl EcssEnumeration, event_id: impl EcssEnumeration,
aux_data: Option<&[u8]>, aux_data: Option<&[u8]>,
@ -132,7 +132,7 @@ impl EventReporterBase {
pub fn event_high_severity<E>( pub fn event_high_severity<E>(
&mut self, &mut self,
buf: &mut [u8], buf: &mut [u8],
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
event_id: impl EcssEnumeration, event_id: impl EcssEnumeration,
aux_data: Option<&[u8]>, aux_data: Option<&[u8]>,
@ -151,7 +151,7 @@ impl EventReporterBase {
&mut self, &mut self,
buf: &mut [u8], buf: &mut [u8],
subservice: Subservices, subservice: Subservices,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
event_id: impl EcssEnumeration, event_id: impl EcssEnumeration,
aux_data: Option<&[u8]>, aux_data: Option<&[u8]>,
@ -220,7 +220,7 @@ mod allocvec {
} }
pub fn event_info<E>( pub fn event_info<E>(
&mut self, &mut self,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
event_id: impl EcssEnumeration, event_id: impl EcssEnumeration,
aux_data: Option<&[u8]>, aux_data: Option<&[u8]>,
@ -236,7 +236,7 @@ mod allocvec {
pub fn event_low_severity<E>( pub fn event_low_severity<E>(
&mut self, &mut self,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
event_id: impl EcssEnumeration, event_id: impl EcssEnumeration,
aux_data: Option<&[u8]>, aux_data: Option<&[u8]>,
@ -252,7 +252,7 @@ mod allocvec {
pub fn event_medium_severity<E>( pub fn event_medium_severity<E>(
&mut self, &mut self,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
event_id: impl EcssEnumeration, event_id: impl EcssEnumeration,
aux_data: Option<&[u8]>, aux_data: Option<&[u8]>,
@ -268,7 +268,7 @@ mod allocvec {
pub fn event_high_severity<E>( pub fn event_high_severity<E>(
&mut self, &mut self,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
event_id: impl EcssEnumeration, event_id: impl EcssEnumeration,
aux_data: Option<&[u8]>, aux_data: Option<&[u8]>,
@ -311,7 +311,7 @@ mod tests {
pub service_queue: VecDeque<TmInfo>, pub service_queue: VecDeque<TmInfo>,
} }
impl EcssTmSenderBase for TestSender { impl EcssTmSenderCore for TestSender {
type Error = (); type Error = ();
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<()>> { fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<()>> {

View File

@ -13,7 +13,7 @@ pub use crate::pus::event::EventReporter;
use crate::pus::verification::{TcStateStarted, VerificationToken}; use crate::pus::verification::{TcStateStarted, VerificationToken};
use crate::pus::EcssTmError; use crate::pus::EcssTmError;
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
use crate::pus::EcssTmSenderBase; use crate::pus::EcssTmSenderCore;
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
pub use alloc_mod::*; pub use alloc_mod::*;
@ -175,7 +175,7 @@ pub mod alloc_mod {
pub fn generate_pus_event_tm_generic<E>( pub fn generate_pus_event_tm_generic<E>(
&mut self, &mut self,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
event: Event, event: Event,
aux_data: Option<&[u8]>, aux_data: Option<&[u8]>,
@ -225,7 +225,7 @@ pub mod alloc_mod {
pub fn generate_pus_event_tm<E, Severity: HasSeverity>( pub fn generate_pus_event_tm<E, Severity: HasSeverity>(
&mut self, &mut self,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
event: EventU32TypedSev<Severity>, event: EventU32TypedSev<Severity>,
aux_data: Option<&[u8]>, aux_data: Option<&[u8]>,
@ -252,7 +252,7 @@ mod tests {
sender: std::sync::mpsc::Sender<Vec<u8>>, sender: std::sync::mpsc::Sender<Vec<u8>>,
} }
impl EcssTmSenderBase for EventTmSender { impl EcssTmSenderCore for EventTmSender {
type Error = SendError<Vec<u8>>; type Error = SendError<Vec<u8>>;
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> { fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> {
let mut vec = Vec::new(); let mut vec = Vec::new();

View File

@ -44,10 +44,8 @@ impl<E> From<ByteConversionError> for EcssTmError<E> {
/// Generic trait for a user supplied sender object. /// Generic trait for a user supplied sender object.
/// ///
/// This sender object is responsible for sending telemetry to a TM sink. The [Downcast] trait /// This sender object is responsible for sending telemetry to a TM sink.
/// is implemented to allow passing the sender as a boxed trait object and still retrieve the pub trait EcssTmSenderCore: Send {
/// concrete type at a later point.
pub trait EcssTmSenderBase: Send {
type Error; type Error;
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>>; fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>>;
@ -57,7 +55,21 @@ pub trait EcssTmSenderBase: Send {
pub mod alloc_mod { pub mod alloc_mod {
use super::*; use super::*;
pub trait EcssTmSender: EcssTmSenderBase + Downcast + DynClone {} /// Extension trait for [EcssTmSenderCore].
///
/// It provides additional functionality, for example by implementing the [Downcast] trait
/// and the [DynClone] trait.
///
/// [Downcast] is implemented to allow passing the sender as a boxed trait object and still
/// retrieve the concrete type at a later point.
///
/// [DynClone] allows cloning the trait object as long as the boxed object implements
/// [Clone].
pub trait EcssTmSender: EcssTmSenderCore + Downcast + DynClone {}
/// Blanket implementation for all types which implement [EcssTmSenderCore] and are clonable.
impl<T> EcssTmSender for T where T: EcssTmSenderCore + Clone + 'static {}
dyn_clone::clone_trait_object!(<T> EcssTmSender<Error=T>); dyn_clone::clone_trait_object!(<T> EcssTmSender<Error=T>);
impl_downcast!(EcssTmSender assoc Error); impl_downcast!(EcssTmSender assoc Error);
} }

View File

@ -72,7 +72,7 @@
//! The [integration test](https://egit.irs.uni-stuttgart.de/rust/fsrc-launchpad/src/branch/main/fsrc-core/tests/verification_test.rs) //! The [integration test](https://egit.irs.uni-stuttgart.de/rust/fsrc-launchpad/src/branch/main/fsrc-core/tests/verification_test.rs)
//! for the verification module contains examples how this module could be used in a more complex //! for the verification module contains examples how this module could be used in a more complex
//! context involving multiple threads //! context involving multiple threads
use crate::pus::{source_buffer_large_enough, EcssTmError, EcssTmSenderBase}; use crate::pus::{source_buffer_large_enough, EcssTmError, EcssTmSenderCore};
use core::fmt::{Display, Formatter}; use core::fmt::{Display, Formatter};
use core::hash::{Hash, Hasher}; use core::hash::{Hash, Hasher};
use core::marker::PhantomData; use core::marker::PhantomData;
@ -91,7 +91,7 @@ pub use crate::seq_count::SimpleSeqCountProvider;
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
pub use alloc_mod::{ pub use alloc_mod::{
VerificationReporterCfg, VerificationReporterWithBuf, VerificationReporterWithSender, VerificationReporter, VerificationReporterCfg, VerificationReporterWithSender,
}; };
use crate::seq_count::SequenceCountProvider; use crate::seq_count::SequenceCountProvider;
@ -289,12 +289,12 @@ impl<'a> FailParamsWithStep<'a> {
} }
#[derive(Clone)] #[derive(Clone)]
pub struct VerificationReporterBasic { pub struct VerificationReporterCore {
pub dest_id: u16, pub dest_id: u16,
apid: u16, apid: u16,
} }
impl VerificationReporterBasic { impl VerificationReporterCore {
pub fn new(apid: u16) -> Option<Self> { pub fn new(apid: u16) -> Option<Self> {
if apid > MAX_APID { if apid > MAX_APID {
return None; return None;
@ -339,7 +339,7 @@ impl VerificationReporterBasic {
&mut self, &mut self,
buf: &mut [u8], buf: &mut [u8],
token: VerificationToken<TcStateNone>, token: VerificationToken<TcStateNone>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized), seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
) -> Result<VerificationToken<TcStateAccepted>, VerificationErrorWithToken<E, TcStateNone>> ) -> Result<VerificationToken<TcStateAccepted>, VerificationErrorWithToken<E, TcStateNone>>
@ -370,7 +370,7 @@ impl VerificationReporterBasic {
&mut self, &mut self,
buf: &mut [u8], buf: &mut [u8],
token: VerificationToken<TcStateNone>, token: VerificationToken<TcStateNone>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized), seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
params: FailParams, params: FailParams,
) -> Result<(), VerificationErrorWithToken<E, TcStateNone>> { ) -> Result<(), VerificationErrorWithToken<E, TcStateNone>> {
@ -398,7 +398,7 @@ impl VerificationReporterBasic {
&mut self, &mut self,
buf: &mut [u8], buf: &mut [u8],
token: VerificationToken<TcStateAccepted>, token: VerificationToken<TcStateAccepted>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized), seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
) -> Result<VerificationToken<TcStateStarted>, VerificationErrorWithToken<E, TcStateAccepted>> ) -> Result<VerificationToken<TcStateStarted>, VerificationErrorWithToken<E, TcStateAccepted>>
@ -431,7 +431,7 @@ impl VerificationReporterBasic {
&mut self, &mut self,
buf: &mut [u8], buf: &mut [u8],
token: VerificationToken<TcStateAccepted>, token: VerificationToken<TcStateAccepted>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized), seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
params: FailParams, params: FailParams,
) -> Result<(), VerificationErrorWithToken<E, TcStateAccepted>> { ) -> Result<(), VerificationErrorWithToken<E, TcStateAccepted>> {
@ -459,7 +459,7 @@ impl VerificationReporterBasic {
&mut self, &mut self,
buf: &mut [u8], buf: &mut [u8],
token: &VerificationToken<TcStateStarted>, token: &VerificationToken<TcStateStarted>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized), seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
step: impl EcssEnumeration, step: impl EcssEnumeration,
@ -485,7 +485,7 @@ impl VerificationReporterBasic {
&mut self, &mut self,
buf: &mut [u8], buf: &mut [u8],
token: VerificationToken<TcStateStarted>, token: VerificationToken<TcStateStarted>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized), seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
params: FailParamsWithStep, params: FailParamsWithStep,
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> { ) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> {
@ -514,7 +514,7 @@ impl VerificationReporterBasic {
&mut self, &mut self,
buf: &mut [u8], buf: &mut [u8],
token: VerificationToken<TcStateStarted>, token: VerificationToken<TcStateStarted>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized), seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> { ) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> {
@ -543,7 +543,7 @@ impl VerificationReporterBasic {
&mut self, &mut self,
buf: &mut [u8], buf: &mut [u8],
token: VerificationToken<TcStateStarted>, token: VerificationToken<TcStateStarted>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized), seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
params: FailParams, params: FailParams,
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> { ) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> {
@ -703,15 +703,15 @@ mod alloc_mod {
/// Primary verification handler. It provides an API to send PUS 1 verification telemetry packets /// Primary verification handler. It provides an API to send PUS 1 verification telemetry packets
/// and verify the various steps of telecommand handling as specified in the PUS standard. /// and verify the various steps of telecommand handling as specified in the PUS standard.
#[derive(Clone)] #[derive(Clone)]
pub struct VerificationReporterWithBuf { pub struct VerificationReporter {
source_data_buf: Vec<u8>, source_data_buf: Vec<u8>,
seq_counter: Box<dyn SequenceCountProviderClonable<u16> + Send + 'static>, seq_counter: Box<dyn SequenceCountProviderClonable<u16> + Send + 'static>,
pub reporter: VerificationReporterBasic, pub reporter: VerificationReporterCore,
} }
impl VerificationReporterWithBuf { impl VerificationReporter {
pub fn new(cfg: &VerificationReporterCfg) -> Self { pub fn new(cfg: &VerificationReporterCfg) -> Self {
let reporter = VerificationReporterBasic::new(cfg.apid).unwrap(); let reporter = VerificationReporterCore::new(cfg.apid).unwrap();
Self { Self {
source_data_buf: vec![ source_data_buf: vec![
0; 0;
@ -744,7 +744,7 @@ mod alloc_mod {
pub fn acceptance_success<E>( pub fn acceptance_success<E>(
&mut self, &mut self,
token: VerificationToken<TcStateNone>, token: VerificationToken<TcStateNone>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
) -> Result<VerificationToken<TcStateAccepted>, VerificationErrorWithToken<E, TcStateNone>> ) -> Result<VerificationToken<TcStateAccepted>, VerificationErrorWithToken<E, TcStateNone>>
{ {
@ -761,7 +761,7 @@ mod alloc_mod {
pub fn acceptance_failure<E>( pub fn acceptance_failure<E>(
&mut self, &mut self,
token: VerificationToken<TcStateNone>, token: VerificationToken<TcStateNone>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
params: FailParams, params: FailParams,
) -> Result<(), VerificationErrorWithToken<E, TcStateNone>> { ) -> Result<(), VerificationErrorWithToken<E, TcStateNone>> {
self.reporter.acceptance_failure( self.reporter.acceptance_failure(
@ -779,7 +779,7 @@ mod alloc_mod {
pub fn start_success<E>( pub fn start_success<E>(
&mut self, &mut self,
token: VerificationToken<TcStateAccepted>, token: VerificationToken<TcStateAccepted>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
) -> Result<VerificationToken<TcStateStarted>, VerificationErrorWithToken<E, TcStateAccepted>> ) -> Result<VerificationToken<TcStateStarted>, VerificationErrorWithToken<E, TcStateAccepted>>
{ {
@ -799,7 +799,7 @@ mod alloc_mod {
pub fn start_failure<E>( pub fn start_failure<E>(
&mut self, &mut self,
token: VerificationToken<TcStateAccepted>, token: VerificationToken<TcStateAccepted>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
params: FailParams, params: FailParams,
) -> Result<(), VerificationErrorWithToken<E, TcStateAccepted>> { ) -> Result<(), VerificationErrorWithToken<E, TcStateAccepted>> {
self.reporter.start_failure( self.reporter.start_failure(
@ -817,7 +817,7 @@ mod alloc_mod {
pub fn step_success<E>( pub fn step_success<E>(
&mut self, &mut self,
token: &VerificationToken<TcStateStarted>, token: &VerificationToken<TcStateStarted>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
step: impl EcssEnumeration, step: impl EcssEnumeration,
) -> Result<(), EcssTmError<E>> { ) -> Result<(), EcssTmError<E>> {
@ -838,7 +838,7 @@ mod alloc_mod {
pub fn step_failure<E>( pub fn step_failure<E>(
&mut self, &mut self,
token: VerificationToken<TcStateStarted>, token: VerificationToken<TcStateStarted>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
params: FailParamsWithStep, params: FailParamsWithStep,
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> { ) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> {
self.reporter.step_failure( self.reporter.step_failure(
@ -857,7 +857,7 @@ mod alloc_mod {
pub fn completion_success<E>( pub fn completion_success<E>(
&mut self, &mut self,
token: VerificationToken<TcStateStarted>, token: VerificationToken<TcStateStarted>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8], time_stamp: &[u8],
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> { ) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> {
self.reporter.completion_success( self.reporter.completion_success(
@ -876,7 +876,7 @@ mod alloc_mod {
pub fn completion_failure<E>( pub fn completion_failure<E>(
&mut self, &mut self,
token: VerificationToken<TcStateStarted>, token: VerificationToken<TcStateStarted>,
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized), sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
params: FailParams, params: FailParams,
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> { ) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> {
self.reporter.completion_failure( self.reporter.completion_failure(
@ -893,7 +893,7 @@ mod alloc_mod {
/// API as [VerificationReporter] but without the explicit sender arguments. /// API as [VerificationReporter] but without the explicit sender arguments.
#[derive(Clone)] #[derive(Clone)]
pub struct VerificationReporterWithSender<E> { pub struct VerificationReporterWithSender<E> {
pub reporter: VerificationReporterWithBuf, pub reporter: VerificationReporter,
pub sender: Box<dyn EcssTmSender<Error = E>>, pub sender: Box<dyn EcssTmSender<Error = E>>,
} }
@ -902,12 +902,12 @@ mod alloc_mod {
cfg: &VerificationReporterCfg, cfg: &VerificationReporterCfg,
sender: Box<dyn EcssTmSender<Error = E>>, sender: Box<dyn EcssTmSender<Error = E>>,
) -> Self { ) -> Self {
let reporter = VerificationReporterWithBuf::new(cfg); let reporter = VerificationReporter::new(cfg);
Self::new_from_reporter(reporter, sender) Self::new_from_reporter(reporter, sender)
} }
pub fn new_from_reporter( pub fn new_from_reporter(
reporter: VerificationReporterWithBuf, reporter: VerificationReporter,
sender: Box<dyn EcssTmSender<Error = E>>, sender: Box<dyn EcssTmSender<Error = E>>,
) -> Self { ) -> Self {
Self { reporter, sender } Self { reporter, sender }
@ -1006,7 +1006,6 @@ mod stdmod {
use super::alloc_mod::VerificationReporterWithSender; use super::alloc_mod::VerificationReporterWithSender;
use super::*; use super::*;
use crate::pool::{ShareablePoolProvider, SharedPool, StoreAddr, StoreError}; use crate::pool::{ShareablePoolProvider, SharedPool, StoreAddr, StoreError};
use crate::pus::alloc_mod::EcssTmSender;
use delegate::delegate; use delegate::delegate;
use spacepackets::tm::PusTm; use spacepackets::tm::PusTm;
use std::sync::{mpsc, Arc, Mutex, RwLockWriteGuard}; use std::sync::{mpsc, Arc, Mutex, RwLockWriteGuard};
@ -1069,7 +1068,7 @@ mod stdmod {
} }
/// Verification sender with a [mpsc::Sender] backend. /// Verification sender with a [mpsc::Sender] backend.
/// It implements the [EcssTmSenderBase] trait to be used as PUS Verification TM sender. /// It implements the [EcssTmSenderCore] 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 {
@ -1079,7 +1078,7 @@ mod stdmod {
} }
//noinspection RsTraitImplementation //noinspection RsTraitImplementation
impl EcssTmSenderBase for MpscVerifSender { impl EcssTmSenderCore for MpscVerifSender {
type Error = StdVerifSenderError; type Error = StdVerifSenderError;
delegate!( delegate!(
@ -1089,8 +1088,6 @@ mod stdmod {
); );
} }
impl EcssTmSender for MpscVerifSender {}
impl SendBackend for crossbeam_channel::Sender<StoreAddr> { impl SendBackend for crossbeam_channel::Sender<StoreAddr> {
fn send(&self, addr: StoreAddr) -> Result<(), StoreAddr> { fn send(&self, addr: StoreAddr) -> Result<(), StoreAddr> {
self.send(addr).map_err(|_| addr) self.send(addr).map_err(|_| addr)
@ -1098,7 +1095,7 @@ mod stdmod {
} }
/// Verification sender with a [crossbeam_channel::Sender] backend. /// Verification sender with a [crossbeam_channel::Sender] backend.
/// It implements the [EcssTmSenderBase] trait to be used as PUS Verification TM sender /// It implements the [EcssTmSenderCore] trait to be used as PUS Verification TM sender
#[cfg(feature = "crossbeam")] #[cfg(feature = "crossbeam")]
#[derive(Clone)] #[derive(Clone)]
pub struct CrossbeamVerifSender { pub struct CrossbeamVerifSender {
@ -1116,7 +1113,7 @@ mod stdmod {
//noinspection RsTraitImplementation //noinspection RsTraitImplementation
#[cfg(feature = "crossbeam")] #[cfg(feature = "crossbeam")]
impl EcssTmSenderBase for CrossbeamVerifSender { impl EcssTmSenderCore for CrossbeamVerifSender {
type Error = StdVerifSenderError; type Error = StdVerifSenderError;
delegate!( delegate!(
@ -1126,10 +1123,7 @@ mod stdmod {
); );
} }
#[cfg(feature = "crossbeam")] impl<S: SendBackend + Clone + 'static> EcssTmSenderCore for StdSenderBase<S> {
impl EcssTmSender for CrossbeamVerifSender {}
impl<S: SendBackend + Clone + 'static> EcssTmSenderBase for StdSenderBase<S> {
type Error = StdVerifSenderError; type Error = StdVerifSenderError;
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> { fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> {
let operation = |mut mg: RwLockWriteGuard<ShareablePoolProvider>| { let operation = |mut mg: RwLockWriteGuard<ShareablePoolProvider>| {
@ -1158,12 +1152,11 @@ mod stdmod {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::pool::{LocalPool, PoolCfg, SharedPool}; use crate::pool::{LocalPool, PoolCfg, SharedPool};
use crate::pus::alloc_mod::EcssTmSender;
use crate::pus::tests::CommonTmInfo; use crate::pus::tests::CommonTmInfo;
use crate::pus::verification::{ use crate::pus::verification::{
EcssTmError, EcssTmSenderBase, FailParams, FailParamsWithStep, MpscVerifSender, RequestId, EcssTmError, EcssTmSenderCore, FailParams, FailParamsWithStep, MpscVerifSender, RequestId,
TcStateNone, VerificationReporterCfg, VerificationReporterWithBuf, TcStateNone, VerificationReporter, VerificationReporterCfg, VerificationReporterWithSender,
VerificationReporterWithSender, VerificationToken, VerificationToken,
}; };
use crate::seq_count::SimpleSeqCountProvider; use crate::seq_count::SimpleSeqCountProvider;
use alloc::boxed::Box; use alloc::boxed::Box;
@ -1196,7 +1189,7 @@ mod tests {
pub service_queue: VecDeque<TmInfo>, pub service_queue: VecDeque<TmInfo>,
} }
impl EcssTmSenderBase for TestSender { impl EcssTmSenderCore for TestSender {
type Error = (); type Error = ();
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> { fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> {
assert_eq!(PusPacket::service(&tm), 1); assert_eq!(PusPacket::service(&tm), 1);
@ -1221,30 +1214,26 @@ mod tests {
} }
} }
impl EcssTmSender for TestSender {}
#[derive(Debug, Copy, Clone, Eq, PartialEq)] #[derive(Debug, Copy, Clone, Eq, PartialEq)]
struct DummyError {} struct DummyError {}
#[derive(Default, Clone)] #[derive(Default, Clone)]
struct FallibleSender {} struct FallibleSender {}
impl EcssTmSenderBase for FallibleSender { impl EcssTmSenderCore for FallibleSender {
type Error = DummyError; type Error = DummyError;
fn send_tm(&mut self, _: PusTm) -> Result<(), EcssTmError<DummyError>> { fn send_tm(&mut self, _: PusTm) -> Result<(), EcssTmError<DummyError>> {
Err(EcssTmError::SendError(DummyError {})) Err(EcssTmError::SendError(DummyError {}))
} }
} }
impl EcssTmSender for FallibleSender {}
struct TestBase<'a> { struct TestBase<'a> {
vr: VerificationReporterWithBuf, vr: VerificationReporter,
#[allow(dead_code)] #[allow(dead_code)]
tc: PusTc<'a>, tc: PusTc<'a>,
} }
impl<'a> TestBase<'a> { impl<'a> TestBase<'a> {
fn rep(&mut self) -> &mut VerificationReporterWithBuf { fn rep(&mut self) -> &mut VerificationReporter {
&mut self.vr &mut self.vr
} }
} }
@ -1255,12 +1244,12 @@ mod tests {
} }
impl<'a, E> TestBaseWithHelper<'a, E> { impl<'a, E> TestBaseWithHelper<'a, E> {
fn rep(&mut self) -> &mut VerificationReporterWithBuf { fn rep(&mut self) -> &mut VerificationReporter {
&mut self.helper.reporter &mut self.helper.reporter
} }
} }
fn base_reporter() -> VerificationReporterWithBuf { fn base_reporter() -> VerificationReporter {
let cfg = VerificationReporterCfg::new( let cfg = VerificationReporterCfg::new(
TEST_APID, TEST_APID,
Box::new(SimpleSeqCountProvider::default()), Box::new(SimpleSeqCountProvider::default()),
@ -1269,7 +1258,7 @@ mod tests {
8, 8,
) )
.unwrap(); .unwrap();
VerificationReporterWithBuf::new(&cfg) VerificationReporter::new(&cfg)
} }
fn base_tc_init(app_data: Option<&[u8]>) -> (PusTc, RequestId) { fn base_tc_init(app_data: Option<&[u8]>) -> (PusTc, RequestId) {

View File

@ -4,7 +4,7 @@
//! 1. [CcsdsDistributor] component which dispatches received packets to a user-provided handler //! 1. [CcsdsDistributor] component which dispatches received packets to a user-provided handler
//! 2. [CcsdsPacketHandler] trait which should be implemented by the user-provided packet handler. //! 2. [CcsdsPacketHandler] trait which should be implemented by the user-provided packet handler.
//! //!
//! The [CcsdsDistributor] implements the [ReceivesCcsdsTc] and [ReceivesTc] trait which allows to //! The [CcsdsDistributor] implements the [ReceivesCcsdsTc] and [ReceivesTcCore] trait which allows to
//! pass raw or CCSDS packets to it. Upon receiving a packet, it performs the following steps: //! pass raw or CCSDS packets to it. Upon receiving a packet, it performs the following steps:
//! //!
//! 1. It tries to identify the target Application Process Identifier (APID) based on the //! 1. It tries to identify the target Application Process Identifier (APID) based on the

View File

@ -5,9 +5,9 @@
//! 2. [PusServiceProvider] trait which should be implemented by the user-provided PUS packet //! 2. [PusServiceProvider] trait which should be implemented by the user-provided PUS packet
//! handler. //! handler.
//! //!
//! The [PusDistributor] implements the [ReceivesEcssPusTc], [ReceivesCcsdsTc] and the [ReceivesTc] //! The [PusDistributor] implements the [ReceivesEcssPusTc], [ReceivesCcsdsTc] and the
//! trait which allows to pass raw packets, CCSDS packets and PUS TC packets into it. //! [ReceivesTcCore] trait which allows to pass raw packets, CCSDS packets and PUS TC packets into
//! Upon receiving a packet, it performs the following steps: //! it. Upon receiving a packet, it performs the following steps:
//! //!
//! 1. It tries to extract the [SpHeader] and [PusTc] objects from the raw bytestream. If this //! 1. It tries to extract the [SpHeader] and [PusTc] objects from the raw bytestream. If this
//! process fails, a [PusDistribError::PusError] is returned to the user. //! process fails, a [PusDistribError::PusError] is returned to the user.

View File

@ -7,7 +7,7 @@ use satrs_core::params::{Params, ParamsHeapless, WritableToBeBytes};
use satrs_core::pus::event_man::{ use satrs_core::pus::event_man::{
DefaultPusMgmtBackendProvider, EventReporter, PusEventDispatcher, DefaultPusMgmtBackendProvider, EventReporter, PusEventDispatcher,
}; };
use satrs_core::pus::{EcssTmError, EcssTmSenderBase}; use satrs_core::pus::{EcssTmError, EcssTmSenderCore};
use spacepackets::ecss::PusPacket; use spacepackets::ecss::PusPacket;
use spacepackets::tm::PusTm; use spacepackets::tm::PusTm;
use std::sync::mpsc::{channel, SendError, TryRecvError}; use std::sync::mpsc::{channel, SendError, TryRecvError};
@ -23,7 +23,7 @@ struct EventTmSender {
sender: std::sync::mpsc::Sender<Vec<u8>>, sender: std::sync::mpsc::Sender<Vec<u8>>,
} }
impl EcssTmSenderBase for EventTmSender { impl EcssTmSenderCore for EventTmSender {
type Error = SendError<Vec<u8>>; type Error = SendError<Vec<u8>>;
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> { fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> {
let mut vec = Vec::new(); let mut vec = Vec::new();

View File

@ -22,7 +22,7 @@ use satrs_core::pus::hk::Subservice;
use satrs_core::pus::verification::{ use satrs_core::pus::verification::{
MpscVerifSender, VerificationReporterCfg, VerificationReporterWithSender, MpscVerifSender, VerificationReporterCfg, VerificationReporterWithSender,
}; };
use satrs_core::pus::{EcssTmError, EcssTmSenderBase}; use satrs_core::pus::{EcssTmError, EcssTmSenderCore};
use satrs_core::seq_count::SimpleSeqCountProvider; use satrs_core::seq_count::SimpleSeqCountProvider;
use satrs_example::{RequestTargetId, OBSW_SERVER_ADDR, SERVER_PORT}; use satrs_example::{RequestTargetId, OBSW_SERVER_ADDR, SERVER_PORT};
use spacepackets::time::cds::TimeProvider; use spacepackets::time::cds::TimeProvider;
@ -51,7 +51,7 @@ impl EventTmSender {
} }
} }
impl EcssTmSenderBase for EventTmSender { impl EcssTmSenderCore for EventTmSender {
type Error = mpsc::SendError<StoreAddr>; type Error = mpsc::SendError<StoreAddr>;
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> { fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> {