feat: rest of droplet calls

This commit is contained in:
DecDuck
2026-02-05 22:36:50 +11:00
parent 006ed0a1f8
commit 454fb19941
7 changed files with 299 additions and 51 deletions
+28 -2
View File
@@ -15,12 +15,23 @@ use tokio::{
use waitmap::WaitMap;
use crate::{
droplet::manifest::generate_manifest,
droplet::{
backend::{has_backend_rpc, list_files_rpc, peek_file_rpc},
call_rpc,
cert::generate_client_cert_rpc,
manifest::generate_manifest_rpc,
},
proto::core::{DropBound, DropBoundType, TorrentialBound, TorrentialBoundType},
};
pub mod download;
macro_rules! spawn_rpc {
($myself:ident, $message:ident, $func_name:ident) => {
spawn(async move { call_rpc($myself.clone(), $message, $func_name).await });
};
}
pub struct DropServer {
server: TcpListener,
write_stream: Mutex<OwnedWriteHalf>,
@@ -50,7 +61,22 @@ impl DropServer {
match message.type_.unwrap() {
TorrentialBoundType::GENERATE_MANIFEST => {
spawn(async move { generate_manifest(myself.clone(), message).await });
spawn_rpc!(myself, message, generate_manifest_rpc);
}
TorrentialBoundType::GENERATE_ROOT_CA => {
spawn_rpc!(myself, message, generate_manifest_rpc);
}
TorrentialBoundType::GENERATE_CLIENT_CERT => {
spawn_rpc!(myself, message, generate_client_cert_rpc);
}
TorrentialBoundType::LIST_FILES_QUERY => {
spawn_rpc!(myself, message, list_files_rpc);
}
TorrentialBoundType::HAS_BACKEND_QUERY => {
spawn_rpc!(myself, message, has_backend_rpc);
}
TorrentialBoundType::PEEK_FILE_QUERY => {
spawn_rpc!(myself, message, peek_file_rpc);
}
_ => {
myself.waitmap.insert(message.message_id.clone(), message);