rustfs_common/lib.rs
1// Copyright 2024 RustFS Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// pub mod error;
16pub mod globals;
17pub mod mrf_channel;
18mod readiness;
19pub mod table_catalog;
20pub mod trace_bus;
21
22pub use globals::*;
23pub use readiness::{GlobalReadiness, SystemStage};
24
25// is ','
26pub static DEFAULT_DELIMITER: u8 = 44;
27
28/// Defers evaluation of a block of code until the end of the scope.
29#[macro_export]
30macro_rules! defer {
31 ($($body:tt)*) => {
32 let _guard = {
33 pub struct Guard<F: FnOnce()>(Option<F>);
34
35 impl<F: FnOnce()> Drop for Guard<F> {
36 fn drop(&mut self) {
37 (self.0).take().map(|f| f());
38 }
39 }
40
41 Guard(Some(|| {
42 let _ = { $($body)* };
43 }))
44 };
45 };
46}