rigela_utils/common.rs
1/*
2 * Copyright (c) 2024. The RigelA open source project team and
3 * its contributors reserve all rights.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the
10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and limitations under the License.
12 */
13
14use win_wrap::common::HMODULE;
15
16#[derive(Clone, Debug)]
17pub struct SafeModuleHandle(HMODULE);
18
19impl SafeModuleHandle {
20 /**
21 创建新实例。
22 */
23 pub fn new(h_module: HMODULE) -> Self {
24 Self(h_module)
25 }
26}
27
28unsafe impl Send for SafeModuleHandle {}
29unsafe impl Sync for SafeModuleHandle {}
30
31impl std::ops::Deref for SafeModuleHandle {
32 type Target = HMODULE;
33
34 fn deref(&self) -> &Self::Target {
35 &self.0
36 }
37}