Simplify MacrosExt helper

This commit is contained in:
David Bürgin 2024-01-15 10:15:35 +01:00
parent 95d1324473
commit 5f60aaccce

View file

@ -72,18 +72,17 @@ impl ConnectionMut for Option<Connection> {
trait MacrosExt {
fn get_string(&self, name: &CStr) -> Option<Cow<'_, str>>;
fn queue_id(&self) -> Cow<'_, str>;
fn queue_id(&self) -> Cow<'_, str> {
self.get_string(c_str!("i"))
.unwrap_or_else(|| "NONE".into())
}
}
impl MacrosExt for Macros {
fn get_string(&self, name: &CStr) -> Option<Cow<'_, str>> {
self.get(name).map(|v| v.to_string_lossy())
}
fn queue_id(&self) -> Cow<'_, str> {
self.get_string(c_str!("i"))
.unwrap_or_else(|| "NONE".into())
}
}
pub fn make_callbacks(config: Config) -> Callbacks<Connection> {