that was annoying

This commit is contained in:
Robin Müller 2023-01-03 20:06:10 +01:00
parent 245388fafa
commit 4effc5bbb3
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -248,17 +248,17 @@ impl<STATE> VerificationToken<STATE> {
} }
/// Composite helper struct to pass failure parameters to the [VerificationReporter] /// Composite helper struct to pass failure parameters to the [VerificationReporter]
pub struct FailParams<'a> { pub struct FailParams<'stamp, 'fargs> {
time_stamp: &'a [u8], time_stamp: &'stamp [u8],
failure_code: &'a dyn EcssEnumeration, failure_code: &'fargs dyn EcssEnumeration,
failure_data: Option<&'a [u8]>, failure_data: Option<&'fargs [u8]>,
} }
impl<'a> FailParams<'a> { impl<'stamp, 'fargs> FailParams<'stamp, 'fargs> {
pub fn new( pub fn new(
time_stamp: &'a [u8], time_stamp: &'stamp [u8],
failure_code: &'a impl EcssEnumeration, failure_code: &'fargs impl EcssEnumeration,
failure_data: Option<&'a [u8]>, failure_data: Option<&'fargs [u8]>,
) -> Self { ) -> Self {
Self { Self {
time_stamp, time_stamp,
@ -269,17 +269,17 @@ impl<'a> FailParams<'a> {
} }
/// Composite helper struct to pass step failure parameters to the [VerificationReporter] /// Composite helper struct to pass step failure parameters to the [VerificationReporter]
pub struct FailParamsWithStep<'a> { pub struct FailParamsWithStep<'stamp, 'fargs> {
bp: FailParams<'a>, bp: FailParams<'stamp, 'fargs>,
step: &'a dyn EcssEnumeration, step: &'fargs dyn EcssEnumeration,
} }
impl<'a> FailParamsWithStep<'a> { impl<'stamp, 'fargs> FailParamsWithStep<'stamp, 'fargs> {
pub fn new( pub fn new(
time_stamp: &'a [u8], time_stamp: &'stamp [u8],
step: &'a impl EcssEnumeration, step: &'fargs impl EcssEnumeration,
failure_code: &'a impl EcssEnumeration, failure_code: &'fargs impl EcssEnumeration,
failure_data: Option<&'a [u8]>, failure_data: Option<&'fargs [u8]>,
) -> Self { ) -> Self {
Self { Self {
bp: FailParams::new(time_stamp, failure_code, failure_data), bp: FailParams::new(time_stamp, failure_code, failure_data),
@ -294,6 +294,84 @@ pub struct VerificationReporterCore {
apid: u16, apid: u16,
} }
pub struct VerificationSendable<'slice, State> {
token: Option<VerificationToken<State>>,
pus_tm: Option<PusTm<'slice>>,
}
impl<'slice, State> VerificationSendable<'slice, State> {
pub fn pus_tm(&self) -> &PusTm<'slice> {
self.pus_tm.as_ref().unwrap()
}
pub fn pus_tm_mut(&mut self) -> &mut PusTm<'slice> {
self.pus_tm.as_mut().unwrap()
}
pub(crate) fn take_tm(&mut self) -> PusTm<'slice> {
self.pus_tm.take().unwrap()
}
pub(crate) fn increment_seq_counter(
&self,
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
) {
if let Some(seq_counter) = seq_counter {
seq_counter.increment();
}
}
pub fn send_success_verif_failure(
self,
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
) {
self.increment_seq_counter(seq_counter);
}
}
impl<'slice> VerificationSendable<'slice, TcStateNone> {
pub fn send_success_acceptance_success(
self,
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
) -> VerificationToken<TcStateAccepted> {
self.increment_seq_counter(seq_counter);
VerificationToken {
state: PhantomData,
req_id: self.token.unwrap().req_id(),
}
}
pub fn send_failure(self) -> (PusTm<'slice>, VerificationToken<TcStateNone>) {
(self.pus_tm.unwrap(), self.token.unwrap())
}
}
impl<'slice> VerificationSendable<'slice, TcStateAccepted> {
pub fn send_success_start_success(
self,
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
) -> VerificationToken<TcStateStarted> {
self.increment_seq_counter(seq_counter);
VerificationToken {
state: PhantomData,
req_id: self.token.unwrap().req_id(),
}
}
pub fn send_failure(self) -> (PusTm<'slice>, VerificationToken<TcStateAccepted>) {
(self.pus_tm.unwrap(), self.token.unwrap())
}
}
impl<'slice> VerificationSendable<'slice, TcStateStarted> {
pub fn send_success_step_or_completion_success(
self,
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
) {
self.increment_seq_counter(seq_counter);
}
pub fn send_failure(self) -> (PusTm<'slice>, Option<VerificationToken<TcStateStarted>>) {
(self.pus_tm.unwrap(), self.token)
}
}
impl VerificationReporterCore { impl VerificationReporterCore {
pub fn new(apid: u16) -> Option<Self> { pub fn new(apid: u16) -> Option<Self> {
if apid > MAX_APID { if apid > MAX_APID {
@ -334,48 +412,60 @@ impl VerificationReporterCore {
VerificationToken::<TcStateNone>::new(req_id) VerificationToken::<TcStateNone>::new(req_id)
} }
/// Package and send a PUS TM\[1, 1\] packet, see 8.1.2.1 of the PUS standard fn sendable_success_no_step<'slice, E, State: Copy>(
pub fn acceptance_success<E>(
&mut self, &mut self,
buf: &mut [u8], buf: &'slice mut [u8],
token: VerificationToken<TcStateNone>, subservice: u8,
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized), token: VerificationToken<State>,
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized), seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
time_stamp: &[u8], time_stamp: &'slice [u8],
) -> Result<VerificationToken<TcStateAccepted>, VerificationErrorWithToken<E, TcStateNone>> ) -> Result<VerificationSendable<'slice, State>, VerificationErrorWithToken<E, State>> {
{ Ok(VerificationSendable {
let tm = self pus_tm: Some(
.create_pus_verif_success_tm( self.create_pus_verif_success_tm(
buf, buf,
Subservice::TmAcceptanceSuccess.into(), subservice,
seq_counter.get(), seq_counter.get(),
&token.req_id, &token.req_id,
time_stamp, time_stamp,
None::<&dyn EcssEnumeration>, None::<&dyn EcssEnumeration>,
) )
.map_err(|e| VerificationErrorWithToken(e, token))?; .map_err(|e| VerificationErrorWithToken(e, token))?,
sender ),
.send_tm(tm) token: Some(token),
.map_err(|e| VerificationErrorWithToken(e, token))?;
seq_counter.increment();
//seq_counter.get_and_increment()
Ok(VerificationToken {
state: PhantomData,
req_id: token.req_id,
}) })
} }
/// Package and send a PUS TM\[1, 2\] packet, see 8.1.2.2 of the PUS standard /// Package a PUS TM\[1, 1\] packet, see 8.1.2.1 of the PUS standard.
pub fn acceptance_failure<E>( pub fn acceptance_success<'slice, E>(
&mut self, &mut self,
buf: &mut [u8], buf: &'slice mut [u8],
token: VerificationToken<TcStateNone>, token: VerificationToken<TcStateNone>,
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized), seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
params: FailParams, time_stamp: &'slice [u8],
) -> Result<(), VerificationErrorWithToken<E, TcStateNone>> { ) -> Result<VerificationSendable<'slice, TcStateNone>, VerificationErrorWithToken<E, TcStateNone>>
let tm = self {
.create_pus_verif_fail_tm( self.sendable_success_no_step(
buf,
Subservice::TmAcceptanceSuccess.into(),
token,
seq_counter,
time_stamp,
)
}
/// Package a PUS TM\[1, 2\] packet, see 8.1.2.2 of the PUS standard.
pub fn acceptance_failure<'slice, E>(
&mut self,
buf: &'slice mut [u8],
token: VerificationToken<TcStateNone>,
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
params: FailParams<'slice, '_>,
) -> Result<VerificationSendable<'slice, TcStateNone>, VerificationErrorWithToken<E, TcStateNone>>
{
Ok(VerificationSendable {
pus_tm: Some(
self.create_pus_verif_fail_tm(
buf, buf,
Subservice::TmAcceptanceFailure.into(), Subservice::TmAcceptanceFailure.into(),
seq_counter.get(), seq_counter.get(),
@ -383,60 +473,51 @@ impl VerificationReporterCore {
None::<&dyn EcssEnumeration>, None::<&dyn EcssEnumeration>,
&params, &params,
) )
.map_err(|e| VerificationErrorWithToken(e, token))?; .map_err(|e| VerificationErrorWithToken(e, token))?,
sender ),
.send_tm(tm) token: Some(token),
.map_err(|e| VerificationErrorWithToken(e, token))?; })
seq_counter.increment();
Ok(())
} }
/// Package and send a PUS TM\[1, 3\] packet, see 8.1.2.3 of the PUS standard. /// Package and send a PUS TM\[1, 3\] packet, see 8.1.2.3 of the PUS standard.
/// ///
/// Requires a token previously acquired by calling [Self::acceptance_success]. /// Requires a token previously acquired by calling [Self::acceptance_success].
pub fn start_success<E>( pub fn start_success<'slice, E>(
&mut self, &mut self,
buf: &mut [u8], buf: &'slice mut [u8],
token: VerificationToken<TcStateAccepted>, token: VerificationToken<TcStateAccepted>,
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized), seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
time_stamp: &[u8], time_stamp: &'slice [u8],
) -> Result<VerificationToken<TcStateStarted>, VerificationErrorWithToken<E, TcStateAccepted>> ) -> Result<
{ VerificationSendable<'slice, TcStateAccepted>,
let tm = self VerificationErrorWithToken<E, TcStateAccepted>,
.create_pus_verif_success_tm( > {
self.sendable_success_no_step(
buf, buf,
Subservice::TmStartSuccess.into(), Subservice::TmStartSuccess.into(),
seq_counter.get(), token,
&token.req_id, seq_counter,
time_stamp, time_stamp,
None::<&dyn EcssEnumeration>,
) )
.map_err(|e| VerificationErrorWithToken(e, token))?;
sender
.send_tm(tm)
.map_err(|e| VerificationErrorWithToken(e, token))?;
seq_counter.increment();
Ok(VerificationToken {
state: PhantomData,
req_id: token.req_id,
})
} }
/// Package and send a PUS TM\[1, 4\] packet, see 8.1.2.4 of the PUS standard. /// Package and send a PUS TM\[1, 4\] packet, see 8.1.2.4 of the PUS standard.
/// ///
/// Requires a token previously acquired by calling [Self::acceptance_success]. It consumes /// Requires a token previously acquired by calling [Self::acceptance_success]. It consumes
/// the token because verification handling is done. /// the token because verification handling is done.
pub fn start_failure<E>( pub fn start_failure<'slice, E>(
&mut self, &mut self,
buf: &mut [u8], buf: &'slice mut [u8],
token: VerificationToken<TcStateAccepted>, token: VerificationToken<TcStateAccepted>,
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized), seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
params: FailParams, params: FailParams<'slice, '_>,
) -> Result<(), VerificationErrorWithToken<E, TcStateAccepted>> { ) -> Result<
let tm = self VerificationSendable<'slice, TcStateAccepted>,
.create_pus_verif_fail_tm( VerificationErrorWithToken<E, TcStateAccepted>,
> {
Ok(VerificationSendable {
pus_tm: Some(
self.create_pus_verif_fail_tm(
buf, buf,
Subservice::TmStartFailure.into(), Subservice::TmStartFailure.into(),
seq_counter.get(), seq_counter.get(),
@ -444,53 +525,53 @@ impl VerificationReporterCore {
None::<&dyn EcssEnumeration>, None::<&dyn EcssEnumeration>,
&params, &params,
) )
.map_err(|e| VerificationErrorWithToken(e, token))?; .map_err(|e| VerificationErrorWithToken(e, token))?,
sender ),
.send_tm(tm) token: Some(token),
.map_err(|e| VerificationErrorWithToken(e, token))?; })
seq_counter.increment();
Ok(())
} }
/// Package and send a PUS TM\[1, 5\] packet, see 8.1.2.5 of the PUS standard. /// Package and send a PUS TM\[1, 5\] packet, see 8.1.2.5 of the PUS standard.
/// ///
/// Requires a token previously acquired by calling [Self::start_success]. /// Requires a token previously acquired by calling [Self::start_success].
pub fn step_success<E>( pub fn step_success<'slice, E>(
&mut self, &mut self,
buf: &mut [u8], buf: &'slice mut [u8],
token: &VerificationToken<TcStateStarted>, token: &VerificationToken<TcStateStarted>,
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized), seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
time_stamp: &[u8], time_stamp: &'slice [u8],
step: impl EcssEnumeration, step: impl EcssEnumeration,
) -> Result<(), EcssTmError<E>> { ) -> Result<VerificationSendable<'slice, TcStateStarted>, EcssTmError<E>> {
let tm = self.create_pus_verif_success_tm( Ok(VerificationSendable {
pus_tm: Some(self.create_pus_verif_success_tm(
buf, buf,
Subservice::TmStepSuccess.into(), Subservice::TmStepSuccess.into(),
seq_counter.get(), seq_counter.get(),
&token.req_id, &token.req_id,
time_stamp, time_stamp,
Some(&step), Some(&step),
)?; )?),
sender.send_tm(tm)?; token: None,
seq_counter.increment(); })
Ok(())
} }
/// Package and send a PUS TM\[1, 6\] packet, see 8.1.2.6 of the PUS standard. /// Package and send a PUS TM\[1, 6\] packet, see 8.1.2.6 of the PUS standard.
/// ///
/// Requires a token previously acquired by calling [Self::start_success]. It consumes the /// Requires a token previously acquired by calling [Self::start_success]. It consumes the
/// token because verification handling is done. /// token because verification handling is done.
pub fn step_failure<E>( pub fn step_failure<'slice, E>(
&mut self, &mut self,
buf: &mut [u8], buf: &'slice mut [u8],
token: VerificationToken<TcStateStarted>, token: VerificationToken<TcStateStarted>,
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized), seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
params: FailParamsWithStep, params: FailParamsWithStep<'slice, '_>,
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> { ) -> Result<
let tm = self VerificationSendable<'slice, TcStateStarted>,
.create_pus_verif_fail_tm( VerificationErrorWithToken<E, TcStateStarted>,
> {
Ok(VerificationSendable {
pus_tm: Some(
self.create_pus_verif_fail_tm(
buf, buf,
Subservice::TmStepFailure.into(), Subservice::TmStepFailure.into(),
seq_counter.get(), seq_counter.get(),
@ -498,57 +579,52 @@ impl VerificationReporterCore {
Some(params.step), Some(params.step),
&params.bp, &params.bp,
) )
.map_err(|e| VerificationErrorWithToken(e, token))?; .map_err(|e| VerificationErrorWithToken(e, token))?,
sender ),
.send_tm(tm) token: Some(token),
.map_err(|e| VerificationErrorWithToken(e, token))?; })
seq_counter.increment();
Ok(())
} }
/// Package and send a PUS TM\[1, 7\] packet, see 8.1.2.7 of the PUS standard. /// Package and send a PUS TM\[1, 7\] packet, see 8.1.2.7 of the PUS standard.
/// ///
/// Requires a token previously acquired by calling [Self::start_success]. It consumes the /// Requires a token previously acquired by calling [Self::start_success]. It consumes the
/// token because verification handling is done. /// token because verification handling is done.
pub fn completion_success<E>( pub fn completion_success<'slice, E>(
&mut self, &mut self,
buf: &mut [u8], buf: &'slice mut [u8],
token: VerificationToken<TcStateStarted>, token: VerificationToken<TcStateStarted>,
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized), seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
time_stamp: &[u8], time_stamp: &'slice [u8],
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> { ) -> Result<
let tm = self VerificationSendable<'slice, TcStateStarted>,
.create_pus_verif_success_tm( VerificationErrorWithToken<E, TcStateStarted>,
> {
self.sendable_success_no_step(
buf, buf,
Subservice::TmCompletionSuccess.into(), Subservice::TmCompletionSuccess.into(),
seq_counter.get(), token,
&token.req_id, seq_counter,
time_stamp, time_stamp,
None::<&dyn EcssEnumeration>,
) )
.map_err(|e| VerificationErrorWithToken(e, token))?;
sender
.send_tm(tm)
.map_err(|e| VerificationErrorWithToken(e, token))?;
seq_counter.increment();
Ok(())
} }
/// Package and send a PUS TM\[1, 8\] packet, see 8.1.2.8 of the PUS standard. /// Package and send a PUS TM\[1, 8\] packet, see 8.1.2.8 of the PUS standard.
/// ///
/// Requires a token previously acquired by calling [Self::start_success]. It consumes the /// Requires a token previously acquired by calling [Self::start_success]. It consumes the
/// token because verification handling is done. /// token because verification handling is done.
pub fn completion_failure<E>( pub fn completion_failure<'slice, E>(
&mut self, &mut self,
buf: &mut [u8], buf: &'slice mut [u8],
token: VerificationToken<TcStateStarted>, token: VerificationToken<TcStateStarted>,
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized), seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
params: FailParams, params: FailParams<'slice, '_>,
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> { ) -> Result<
let tm = self VerificationSendable<'slice, TcStateStarted>,
.create_pus_verif_fail_tm( VerificationErrorWithToken<E, TcStateStarted>,
> {
Ok(VerificationSendable {
pus_tm: Some(
self.create_pus_verif_fail_tm(
buf, buf,
Subservice::TmCompletionFailure.into(), Subservice::TmCompletionFailure.into(),
seq_counter.get(), seq_counter.get(),
@ -556,23 +632,21 @@ impl VerificationReporterCore {
None::<&dyn EcssEnumeration>, None::<&dyn EcssEnumeration>,
&params, &params,
) )
.map_err(|e| VerificationErrorWithToken(e, token))?; .map_err(|e| VerificationErrorWithToken(e, token))?,
sender ),
.send_tm(tm) token: Some(token),
.map_err(|e| VerificationErrorWithToken(e, token))?; })
seq_counter.increment();
Ok(())
} }
fn create_pus_verif_success_tm<'a, E>( fn create_pus_verif_success_tm<'slice, E>(
&'a mut self, &mut self,
buf: &'a mut [u8], buf: &'slice mut [u8],
subservice: u8, subservice: u8,
msg_counter: u16, msg_counter: u16,
req_id: &RequestId, req_id: &RequestId,
time_stamp: &'a [u8], time_stamp: &'slice [u8],
step: Option<&(impl EcssEnumeration + ?Sized)>, step: Option<&(impl EcssEnumeration + ?Sized)>,
) -> Result<PusTm, EcssTmError<E>> { ) -> Result<PusTm<'slice>, EcssTmError<E>> {
let mut source_data_len = size_of::<u32>(); let mut source_data_len = size_of::<u32>();
if let Some(step) = step { if let Some(step) = step {
source_data_len += step.byte_width(); source_data_len += step.byte_width();
@ -597,15 +671,15 @@ impl VerificationReporterCore {
)) ))
} }
fn create_pus_verif_fail_tm<'a, E>( fn create_pus_verif_fail_tm<'slice, E>(
&'a mut self, &mut self,
buf: &'a mut [u8], buf: &'slice mut [u8],
subservice: u8, subservice: u8,
msg_counter: u16, msg_counter: u16,
req_id: &RequestId, req_id: &RequestId,
step: Option<&(impl EcssEnumeration + ?Sized)>, step: Option<&(impl EcssEnumeration + ?Sized)>,
params: &'a FailParams, params: &FailParams<'slice, '_>,
) -> Result<PusTm, EcssTmError<E>> { ) -> Result<PusTm<'slice>, EcssTmError<E>> {
let mut idx = 0; let mut idx = 0;
let mut source_data_len = RequestId::SIZE_AS_BYTES + params.failure_code.byte_width(); let mut source_data_len = RequestId::SIZE_AS_BYTES + params.failure_code.byte_width();
if let Some(step) = step { if let Some(step) = step {
@ -641,15 +715,15 @@ impl VerificationReporterCore {
)) ))
} }
fn create_pus_verif_tm_base<'a>( fn create_pus_verif_tm_base<'slice>(
&'a mut self, &mut self,
buf: &'a mut [u8], buf: &'slice mut [u8],
subservice: u8, subservice: u8,
msg_counter: u16, msg_counter: u16,
sp_header: &mut SpHeader, sp_header: &mut SpHeader,
time_stamp: &'a [u8], time_stamp: &'slice [u8],
source_data_len: usize, source_data_len: usize,
) -> PusTm { ) -> PusTm<'slice> {
let tm_sec_header = let tm_sec_header =
PusTmSecondaryHeader::new(1, subservice, msg_counter, self.dest_id, time_stamp); PusTmSecondaryHeader::new(1, subservice, msg_counter, self.dest_id, time_stamp);
PusTm::new( PusTm::new(
@ -748,13 +822,17 @@ mod alloc_mod {
time_stamp: &[u8], time_stamp: &[u8],
) -> Result<VerificationToken<TcStateAccepted>, VerificationErrorWithToken<E, TcStateNone>> ) -> Result<VerificationToken<TcStateAccepted>, VerificationErrorWithToken<E, TcStateNone>>
{ {
self.reporter.acceptance_success( let mut sendable = self.reporter.acceptance_success(
self.source_data_buf.as_mut_slice(), self.source_data_buf.as_mut_slice(),
token, token,
sender, self.seq_counter.as_ref(),
self.seq_counter.as_mut(),
time_stamp, time_stamp,
) )?;
sender
.send_tm(sendable.take_tm())
.map_err(|e| VerificationErrorWithToken(e, token))?;
let token = sendable.send_success_acceptance_success(Some(self.seq_counter.as_ref()));
Ok(token)
} }
/// Package and send a PUS TM\[1, 2\] packet, see 8.1.2.2 of the PUS standard /// Package and send a PUS TM\[1, 2\] packet, see 8.1.2.2 of the PUS standard
@ -764,13 +842,17 @@ mod alloc_mod {
sender: &mut (impl EcssTmSenderCore<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( let mut sendable = self.reporter.acceptance_failure(
self.source_data_buf.as_mut_slice(), self.source_data_buf.as_mut_slice(),
token, token,
sender, self.seq_counter.as_ref(),
self.seq_counter.as_mut(),
params, params,
) )?;
sender
.send_tm(sendable.take_tm())
.map_err(|e| VerificationErrorWithToken(e, token))?;
sendable.send_success_verif_failure(Some(self.seq_counter.as_ref()));
Ok(())
} }
/// Package and send a PUS TM\[1, 3\] packet, see 8.1.2.3 of the PUS standard. /// Package and send a PUS TM\[1, 3\] packet, see 8.1.2.3 of the PUS standard.
@ -783,13 +865,17 @@ mod alloc_mod {
time_stamp: &[u8], time_stamp: &[u8],
) -> Result<VerificationToken<TcStateStarted>, VerificationErrorWithToken<E, TcStateAccepted>> ) -> Result<VerificationToken<TcStateStarted>, VerificationErrorWithToken<E, TcStateAccepted>>
{ {
self.reporter.start_success( let mut sendable = self.reporter.start_success(
self.source_data_buf.as_mut_slice(), self.source_data_buf.as_mut_slice(),
token, token,
sender,
self.seq_counter.as_mut(), self.seq_counter.as_mut(),
time_stamp, time_stamp,
) )?;
sender
.send_tm(sendable.take_tm())
.map_err(|e| VerificationErrorWithToken(e, token))?;
let token = sendable.send_success_start_success(Some(self.seq_counter.as_ref()));
Ok(token)
} }
/// Package and send a PUS TM\[1, 4\] packet, see 8.1.2.4 of the PUS standard. /// Package and send a PUS TM\[1, 4\] packet, see 8.1.2.4 of the PUS standard.
@ -802,13 +888,17 @@ mod alloc_mod {
sender: &mut (impl EcssTmSenderCore<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( let mut sendable = self.reporter.start_failure(
self.source_data_buf.as_mut_slice(), self.source_data_buf.as_mut_slice(),
token, token,
sender,
self.seq_counter.as_mut(), self.seq_counter.as_mut(),
params, params,
) )?;
sender
.send_tm(sendable.take_tm())
.map_err(|e| VerificationErrorWithToken(e, token))?;
sendable.send_success_verif_failure(Some(self.seq_counter.as_ref()));
Ok(())
} }
/// Package and send a PUS TM\[1, 5\] packet, see 8.1.2.5 of the PUS standard. /// Package and send a PUS TM\[1, 5\] packet, see 8.1.2.5 of the PUS standard.
@ -821,14 +911,16 @@ mod alloc_mod {
time_stamp: &[u8], time_stamp: &[u8],
step: impl EcssEnumeration, step: impl EcssEnumeration,
) -> Result<(), EcssTmError<E>> { ) -> Result<(), EcssTmError<E>> {
self.reporter.step_success( let mut sendable = self.reporter.step_success(
self.source_data_buf.as_mut_slice(), self.source_data_buf.as_mut_slice(),
token, token,
sender,
self.seq_counter.as_mut(), self.seq_counter.as_mut(),
time_stamp, time_stamp,
step, step,
) )?;
sender.send_tm(sendable.take_tm())?;
sendable.send_success_step_or_completion_success(Some(self.seq_counter.as_ref()));
Ok(())
} }
/// Package and send a PUS TM\[1, 6\] packet, see 8.1.2.6 of the PUS standard. /// Package and send a PUS TM\[1, 6\] packet, see 8.1.2.6 of the PUS standard.
@ -841,13 +933,17 @@ mod alloc_mod {
sender: &mut (impl EcssTmSenderCore<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( let mut sendable = self.reporter.step_failure(
self.source_data_buf.as_mut_slice(), self.source_data_buf.as_mut_slice(),
token, token,
sender,
self.seq_counter.as_mut(), self.seq_counter.as_mut(),
params, params,
) )?;
sender
.send_tm(sendable.take_tm())
.map_err(|e| VerificationErrorWithToken(e, token))?;
sendable.send_success_step_or_completion_success(Some(self.seq_counter.as_ref()));
Ok(())
} }
/// Package and send a PUS TM\[1, 7\] packet, see 8.1.2.7 of the PUS standard. /// Package and send a PUS TM\[1, 7\] packet, see 8.1.2.7 of the PUS standard.
@ -860,13 +956,17 @@ mod alloc_mod {
sender: &mut (impl EcssTmSenderCore<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( let mut sendable = self.reporter.completion_success(
self.source_data_buf.as_mut_slice(), self.source_data_buf.as_mut_slice(),
token, token,
sender,
self.seq_counter.as_mut(), self.seq_counter.as_mut(),
time_stamp, time_stamp,
) )?;
sender
.send_tm(sendable.take_tm())
.map_err(|e| VerificationErrorWithToken(e, token))?;
sendable.send_success_step_or_completion_success(Some(self.seq_counter.as_ref()));
Ok(())
} }
/// Package and send a PUS TM\[1, 8\] packet, see 8.1.2.8 of the PUS standard. /// Package and send a PUS TM\[1, 8\] packet, see 8.1.2.8 of the PUS standard.
@ -879,13 +979,17 @@ mod alloc_mod {
sender: &mut (impl EcssTmSenderCore<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( let mut sendable = self.reporter.completion_failure(
self.source_data_buf.as_mut_slice(), self.source_data_buf.as_mut_slice(),
token, token,
sender,
self.seq_counter.as_mut(), self.seq_counter.as_mut(),
params, params,
) )?;
sender
.send_tm(sendable.take_tm())
.map_err(|e| VerificationErrorWithToken(e, token))?;
sendable.send_success_step_or_completion_success(Some(self.seq_counter.as_ref()));
Ok(())
} }
} }