arch_pkg_text/desc/query/generic/
parking_lot_ext.rs1use crate::desc::{ParsedField, Query, QueryMut, misc::ReuseAdvice};
2use parking_lot::{FairMutex, Mutex, RwLock};
3
4macro_rules! impl_lock {
5 ($wrapper:ident, $lock:ident) => {
6 impl<'a, Querier: QueryMut<'a> + ?Sized> Query<'a> for $wrapper<Querier> {
7 fn query_raw_text(&self, field: ParsedField) -> Option<&'a str> {
8 self.$lock().query_raw_text_mut(field)
9 }
10 }
11
12 impl<'a, Querier: QueryMut<'a> + ?Sized> QueryMut<'a> for $wrapper<Querier> {
13 fn query_raw_text_mut(&mut self, field: ParsedField) -> Option<&'a str> {
14 self.query_raw_text(field)
15 }
16 }
17
18 impl<Querier: ReuseAdvice + ?Sized> ReuseAdvice for $wrapper<Querier> {
19 type ShouldReuse = Querier::ShouldReuse;
20 }
21 };
22}
23
24impl_lock!(Mutex, lock);
25impl_lock!(FairMutex, lock);
26impl_lock!(RwLock, write);