Debian Codegraph @

third_party/rust/wio/src/error.rs

raw
1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 use std::result;
7 use winapi::shared::minwindef::DWORD;
8 use winapi::um::errhandlingapi::GetLastError;
9 #[derive(Clone, Copy, Debug)]
10 pub struct Error(DWORD);
11 impl Error {
12 pub fn code(&self) -> u32 { self.0 }
13 pub fn last<T>() -> Result<T> {
14 Err(Error(unsafe { GetLastError() }))
15 }
16 }
17
18 pub type Result<T> = result::Result<T, Error>;