Implement Display for the error enum
All checks were successful
Build library & run tests / build (unix) (push) Successful in 33s
Build library & run tests / build (tcp) (push) Successful in 35s
Build library & run tests / docs (push) Successful in 36s

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

View File

@ -335,11 +335,19 @@ fn derive_protocol(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream
// Create an error and result type for sending messages
let error_enum = quote! {
#[derive(Debug)]
#[derive(::std::fmt::Debug)]
#vis enum #error_enum_name {
SendError(::tokio::sync::mpsc::error::SendError<(u64, #question_enum_name)>),
Closed,
}
impl ::std::fmt::Display for #error_enum_name {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
#error_enum_name::SendError(e) => write!(f, "Failed to send query: {}", e),
#error_enum_name::Closed => write!(f, "Connection closed"),
}
}
}
};
// Create enums for the types of messages the server and client will use