a blanket impl makes this easier
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
//! UDP server helper components
|
||||
use crate::tmtc::{ReceivesTc, ReceivesTcBase};
|
||||
use crate::tmtc::{ReceivesTc, ReceivesTcCore};
|
||||
use std::boxed::Box;
|
||||
use std::io::{Error, ErrorKind};
|
||||
use std::net::{SocketAddr, ToSocketAddrs, UdpSocket};
|
||||
@ -19,20 +19,19 @@ use std::vec::Vec;
|
||||
/// ```
|
||||
/// use std::net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket};
|
||||
/// use satrs_core::hal::host::udp_server::UdpTcServer;
|
||||
/// use satrs_core::tmtc::{ReceivesTc, ReceivesTcBase};
|
||||
/// use satrs_core::tmtc::{ReceivesTc, ReceivesTcCore};
|
||||
/// use spacepackets::SpHeader;
|
||||
/// use spacepackets::tc::PusTc;
|
||||
///
|
||||
/// #[derive (Default)]
|
||||
/// struct PingReceiver {}
|
||||
/// impl ReceivesTcBase for PingReceiver {
|
||||
/// impl ReceivesTcCore for PingReceiver {
|
||||
/// type Error = ();
|
||||
/// fn pass_tc(&mut self, tc_raw: &[u8]) -> Result<(), Self::Error> {
|
||||
/// assert_eq!(tc_raw.len(), 13);
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// }
|
||||
/// impl ReceivesTc for PingReceiver {}
|
||||
///
|
||||
/// let mut buf = [0; 32];
|
||||
/// let dest_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 7777);
|
||||
@ -90,7 +89,7 @@ impl<E: PartialEq> PartialEq for ReceiveResult<E> {
|
||||
|
||||
impl<E: Eq + PartialEq> Eq for ReceiveResult<E> {}
|
||||
|
||||
impl<E: 'static> ReceivesTcBase for UdpTcServer<E> {
|
||||
impl<E: 'static> ReceivesTcCore for UdpTcServer<E> {
|
||||
type Error = E;
|
||||
|
||||
fn pass_tc(&mut self, tc_raw: &[u8]) -> Result<(), Self::Error> {
|
||||
@ -98,8 +97,6 @@ impl<E: 'static> ReceivesTcBase for UdpTcServer<E> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: 'static> ReceivesTc for UdpTcServer<E> {}
|
||||
|
||||
impl<E: 'static> UdpTcServer<E> {
|
||||
pub fn new<A: ToSocketAddrs>(
|
||||
addr: A,
|
||||
@ -143,7 +140,7 @@ impl<E: 'static> UdpTcServer<E> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::hal::host::udp_server::{ReceiveResult, UdpTcServer};
|
||||
use crate::tmtc::{ReceivesTc, ReceivesTcBase};
|
||||
use crate::tmtc::ReceivesTcCore;
|
||||
use spacepackets::tc::PusTc;
|
||||
use spacepackets::SpHeader;
|
||||
use std::boxed::Box;
|
||||
@ -158,7 +155,7 @@ mod tests {
|
||||
pub sent_cmds: VecDeque<Vec<u8>>,
|
||||
}
|
||||
|
||||
impl ReceivesTcBase for PingReceiver {
|
||||
impl ReceivesTcCore for PingReceiver {
|
||||
type Error = ();
|
||||
|
||||
fn pass_tc(&mut self, tc_raw: &[u8]) -> Result<(), Self::Error> {
|
||||
@ -169,8 +166,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
impl ReceivesTc for PingReceiver {}
|
||||
|
||||
#[test]
|
||||
fn basic_test() {
|
||||
let mut buf = [0; 32];
|
||||
|
Reference in New Issue
Block a user