Skip to content

Commit 1c3d647

Browse files
committed
test: add TestRequest
1 parent 47cc504 commit 1c3d647

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

shared/src/conn/msg_dispatch.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,45 @@ 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+
pub msg_id: MsgId,
110+
pub authenticate_connection: bool,
111+
}
112+
113+
impl TestRequest {
114+
pub fn new(msg_id: MsgId) -> Self {
115+
Self {
116+
msg_id,
117+
authenticate_connection: false,
118+
}
119+
}
120+
}
121+
122+
impl Request for TestRequest {
123+
async fn respond<M: Msg + Serializable>(self, _msg: &M) -> Result<()> {
124+
// do nothing
125+
Ok(())
126+
}
127+
128+
fn authenticate_connection(&mut self) {
129+
self.authenticate_connection = true;
130+
}
131+
132+
fn addr(&self) -> SocketAddr {
133+
SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 0).into()
134+
}
135+
136+
fn msg_id(&self) -> MsgId {
137+
self.msg_id
138+
}
139+
140+
fn deserialize_msg<M: Msg + Deserializable>(&self) -> Result<M> {
141+
unimplemented!()
142+
}
143+
}
144+
}

0 commit comments

Comments
 (0)