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
15pub mod bucket_stats;
16// pub mod error;
17pub mod globals;
18pub mod last_minute;
19
20// is ','
21pub static DEFAULT_DELIMITER: u8 = 44;
22
23/// Defers evaluation of a block of code until the end of the scope.
24#[macro_export]
25macro_rules! defer {
26 ($($body:tt)*) => {
27 let _guard = {
28 pub struct Guard<F: FnOnce()>(Option<F>);
29
30 impl<F: FnOnce()> Drop for Guard<F> {
31 fn drop(&mut self) {
32 (self.0).take().map(|f| f());
33 }
34 }
35
36 Guard(Some(|| {
37 let _ = { $($body)* };
38 }))
39 };
40 };
41}