implement Drop for client struct
Some checks failed
Build library & run tests / docs (push) Failing after 23s
Build library & run tests / build (unix) (push) Failing after 29s
Build library & run tests / build (tcp) (push) Failing after 30s

This commit is contained in:
Kodi Craft 2024-06-24 23:40:47 +02:00
parent b5870e62fe
commit 00fb24c0d2
Signed by: kodi
GPG Key ID: 69D9EED60B242822

View File

@ -618,7 +618,7 @@ fn derive_protocol(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream
// Create a struct which the client will use to communicate // Create a struct which the client will use to communicate
let client_recv_queue_wrapper = format_ident!("__{}RecvQueueWrapper", name); let client_recv_queue_wrapper = format_ident!("__{}RecvQueueWrapper", name);
let client_struct = quote! { let client_struct = quote! {
#[derive(Clone)] #[derive(::std::clone::Clone)]
struct #client_recv_queue_wrapper { struct #client_recv_queue_wrapper {
recv_queue: ::std::sync::Arc<::tokio::sync::Mutex<::tokio::sync::mpsc::Receiver<(u64, #answer_enum_name)>>>, recv_queue: ::std::sync::Arc<::tokio::sync::Mutex<::tokio::sync::mpsc::Receiver<(u64, #answer_enum_name)>>>,
} }
@ -707,6 +707,11 @@ fn derive_protocol(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream
} }
#(#client_impl)* #(#client_impl)*
} }
impl std::drop::Drop for #client_struct_name {
fn drop(&mut self) {
self.close();
}
}
}; };
let expanded = quote! { let expanded = quote! {