Skip to content

Commit cb906ad

Browse files
committed
test: add TestRequest
1 parent 15d1bd0 commit cb906ad

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

shared/src/conn/msg_dispatch.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,41 @@ impl Request for SocketRequest<'_> {
100100
self.header.msg_id()
101101
}
102102
}
103+
104+
pub mod test {
105+
use super::*;
106+
use std::net::{Ipv4Addr, SocketAddrV4};
107+
108+
pub struct TestRequest {
109+
msg_id: MsgId,
110+
}
111+
112+
impl TestRequest {
113+
pub fn new(msg_id: MsgId) -> Self {
114+
Self { msg_id }
115+
}
116+
}
117+
118+
impl Request for TestRequest {
119+
async fn respond<M: Msg + Serializable>(self, _msg: &M) -> Result<()> {
120+
// do nothing
121+
Ok(())
122+
}
123+
124+
fn authenticate_connection(&mut self) {
125+
// do nothing
126+
}
127+
128+
fn addr(&self) -> SocketAddr {
129+
SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 0).into()
130+
}
131+
132+
fn msg_id(&self) -> MsgId {
133+
self.msg_id
134+
}
135+
136+
fn deserialize_msg<M: Msg + Deserializable>(&self) -> Result<M> {
137+
unimplemented!()
138+
}
139+
}
140+
}

0 commit comments

Comments
 (0)