1 // Copyright (c) 2023 Huawei Device Co., Ltd. 2 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // you may not use this file except in compliance with the License. 4 // You may obtain a copy of the License at 5 // 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 use std::fmt; 15 use std::ops::{Deref, DerefMut}; 16 17 use crate::sys::winapi::{IO_STATUS_BLOCK, IO_STATUS_BLOCK_0}; 18 19 pub(crate) struct IoStatusBlock(IO_STATUS_BLOCK); 20 21 unsafe impl Send for IoStatusBlock {} 22 23 impl IoStatusBlock { zeroed() -> Self24 pub(crate) fn zeroed() -> Self { 25 Self(IO_STATUS_BLOCK { 26 Anonymous: IO_STATUS_BLOCK_0 { Status: 0 }, 27 Information: 0, 28 }) 29 } 30 } 31 32 impl Deref for IoStatusBlock { 33 type Target = IO_STATUS_BLOCK; deref(&self) -> &Self::Target34 fn deref(&self) -> &Self::Target { 35 &self.0 36 } 37 } 38 39 impl DerefMut for IoStatusBlock { deref_mut(&mut self) -> &mut Self::Target40 fn deref_mut(&mut self) -> &mut Self::Target { 41 &mut self.0 42 } 43 } 44 45 impl fmt::Debug for IoStatusBlock { fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result46 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 47 f.debug_struct("IoStatusBlock").finish() 48 } 49 } 50