update docs

This commit is contained in:
2024-04-14 19:16:56 +02:00
parent 12320c04ae
commit b2c00103db
16 changed files with 135 additions and 167 deletions

View File

@ -116,6 +116,7 @@ impl<
#[cfg(test)]
mod tests {
use std::{
cell::RefCell,
collections::VecDeque,
net::IpAddr,
sync::{Arc, Mutex},
@ -134,13 +135,14 @@ mod tests {
#[derive(Default, Debug)]
pub struct TestSender {
tc_vec: VecDeque<Vec<u8>>,
tc_vec: RefCell<VecDeque<Vec<u8>>>,
}
impl PacketSenderRaw for TestSender {
type Error = ();
fn send_raw_tc(&mut self, tc_raw: &[u8]) -> Result<(), Self::Error> {
self.tc_vec.push_back(tc_raw.to_vec());
fn send_raw_tc(&self, tc_raw: &[u8]) -> Result<(), Self::Error> {
let mut mut_queue = self.tc_vec.borrow_mut();
mut_queue.push_back(tc_raw.to_vec());
Ok(())
}
}
@ -169,7 +171,8 @@ mod tests {
tm_handler,
};
udp_dyn_server.periodic_operation();
assert!(udp_dyn_server.udp_tc_server.tc_sender.tc_vec.is_empty());
let queue = udp_dyn_server.udp_tc_server.tc_sender.tc_vec.borrow();
assert!(queue.is_empty());
assert!(tm_handler_calls.lock().unwrap().is_empty());
}
@ -196,15 +199,9 @@ mod tests {
client.send(&ping_tc).unwrap();
udp_dyn_server.periodic_operation();
{
//let mut tc_queue = tc_queue.lock().unwrap();
assert!(!udp_dyn_server.udp_tc_server.tc_sender.tc_vec.is_empty());
let received_tc = udp_dyn_server
.udp_tc_server
.tc_sender
.tc_vec
.pop_front()
.unwrap();
assert_eq!(received_tc, ping_tc);
let mut queue = udp_dyn_server.udp_tc_server.tc_sender.tc_vec.borrow_mut();
assert!(!queue.is_empty());
assert_eq!(queue.pop_front().unwrap(), ping_tc);
}
{
@ -215,7 +212,9 @@ mod tests {
assert_eq!(received_addr, client_addr);
}
udp_dyn_server.periodic_operation();
assert!(udp_dyn_server.udp_tc_server.tc_sender.tc_vec.is_empty());
let queue = udp_dyn_server.udp_tc_server.tc_sender.tc_vec.borrow();
assert!(queue.is_empty());
drop(queue);
// Still tries to send to the same client.
{
let mut tm_handler_calls = tm_handler_calls.lock().unwrap();

View File

@ -180,8 +180,9 @@ pub trait TargetedPusService {
///
/// The handler exposes the following API:
///
/// 1. [Self::handle_one_tc] which tries to poll and handle one TC packet, covering steps 1-5.
/// 2. [Self::check_one_reply] which tries to poll and handle one reply, covering step 6.
/// 1. [Self::poll_and_handle_next_tc] which tries to poll and handle one TC packet, covering
/// steps 1-5.
/// 2. [Self::poll_and_check_next_reply] which tries to poll and handle one reply, covering step 6.
/// 3. [Self::check_for_request_timeouts] which checks for request timeouts, covering step 7.
pub struct PusTargetedRequestService<
TcReceiver: EcssTcReceiverCore,