work (new network + db initial working state)

This commit is contained in:
2026-02-15 16:59:47 -05:00
parent a8b55f669f
commit 8be13e14bc
14 changed files with 418 additions and 232 deletions

View File

@@ -1,5 +1,5 @@
use openworm::net::{
ClientMsg, ClientMsgInst, RecvHandler, SERVER_NAME, SendResult, ServerMsg, ServerMsgInst,
ClientRequestMsg, RecvHandler, RequestId, SERVER_NAME, SendResult, ServerMsg, ServerRespMsg,
recv_uni, send_uni,
};
use quinn::{
@@ -63,8 +63,34 @@ impl ClientSender {
pub fn remote(&self) -> SocketAddr {
self.conn.remote_address()
}
pub fn replier(&self, id: RequestId) -> ClientReplier {
ClientReplier {
conn: self.conn.clone(),
req_id: id,
}
}
pub async fn send(&self, msg: impl Into<ServerMsg>) -> SendResult {
let msg = ServerMsgInst::from(msg.into());
let msg = ServerRespMsg {
id: None,
msg: msg.into().into(),
};
send_uni(&self.conn, msg).await
}
}
pub struct ClientReplier {
conn: Connection,
req_id: RequestId,
}
impl ClientReplier {
pub async fn send(&self, msg: impl Into<ServerMsg>) -> SendResult {
let msg = ServerRespMsg {
id: Some(self.req_id),
msg: msg.into().into(),
};
send_uni(&self.conn, msg).await
}
}
@@ -73,7 +99,7 @@ pub trait ConAccepter: Send + Sync + 'static {
fn accept(
&self,
send: ClientSender,
) -> impl Future<Output = impl RecvHandler<ClientMsgInst>> + Send;
) -> impl Future<Output = impl RecvHandler<ClientRequestMsg>> + Send;
}
pub fn listen(