| 1 |
// Copyright 2016 The Servo Project Developers. See the COPYRIGHT |
| 2 |
// file at the top-level directory of this distribution. |
| 3 |
// |
| 4 |
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 5 |
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 6 |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 7 |
// option. This file may not be copied, modified, or distributed |
| 8 |
// except according to those terms. |
| 9 |
|
| 10 |
use std::os::raw::c_void; |
| 11 |
|
| 12 |
use crate::base::{CFAllocatorRef, CFIndex, CFTypeID}; |
| 13 |
use crate::dictionary::CFDictionaryRef; |
| 14 |
use crate::string::CFStringRef; |
| 15 |
|
| 16 |
#[repr(C)] |
| 17 |
pub struct __CFError(c_void); |
| 18 |
|
| 19 |
pub type CFErrorRef = *mut __CFError; |
| 20 |
pub type CFErrorDomain = CFStringRef; |
| 21 |
|
| 22 |
extern "C" { |
| 23 |
/* |
| 24 |
* CFError.h |
| 25 |
*/ |
| 26 |
|
| 27 |
/* Error domains */ |
| 28 |
pub static kCFErrorDomainPOSIX: CFStringRef; |
| 29 |
pub static kCFErrorDomainOSStatus: CFStringRef; |
| 30 |
pub static kCFErrorDomainMach: CFStringRef; |
| 31 |
pub static kCFErrorDomainCocoa: CFStringRef; |
| 32 |
|
| 33 |
/* Keys for the user info dictionary */ |
| 34 |
pub static kCFErrorLocalizedDescriptionKey: CFStringRef; |
| 35 |
// pub static kCFErrorLocalizedFailureKey: CFStringRef; // macos(10.13)+ |
| 36 |
pub static kCFErrorLocalizedFailureReasonKey: CFStringRef; |
| 37 |
pub static kCFErrorLocalizedRecoverySuggestionKey: CFStringRef; |
| 38 |
pub static kCFErrorDescriptionKey: CFStringRef; |
| 39 |
pub static kCFErrorUnderlyingErrorKey: CFStringRef; |
| 40 |
pub static kCFErrorURLKey: CFStringRef; |
| 41 |
pub static kCFErrorFilePathKey: CFStringRef; |
| 42 |
|
| 43 |
/* Creating a CFError */ |
| 44 |
pub fn CFErrorCreate( |
| 45 |
allocator: CFAllocatorRef, |
| 46 |
domain: CFErrorDomain, |
| 47 |
code: CFIndex, |
| 48 |
userInfo: CFDictionaryRef, |
| 49 |
) -> CFErrorRef; |
| 50 |
//pub fn CFErrorCreateWithUserInfoKeysAndValues |
| 51 |
|
| 52 |
/* Getting Information About an Error */ |
| 53 |
pub fn CFErrorGetDomain(err: CFErrorRef) -> CFStringRef; |
| 54 |
pub fn CFErrorGetCode(err: CFErrorRef) -> CFIndex; |
| 55 |
pub fn CFErrorCopyUserInfo(err: CFErrorRef) -> CFDictionaryRef; |
| 56 |
pub fn CFErrorCopyDescription(err: CFErrorRef) -> CFStringRef; |
| 57 |
pub fn CFErrorCopyFailureReason(err: CFErrorRef) -> CFStringRef; |
| 58 |
pub fn CFErrorCopyRecoverySuggestion(err: CFErrorRef) -> CFStringRef; |
| 59 |
|
| 60 |
/* Getting the CFError Type ID */ |
| 61 |
pub fn CFErrorGetTypeID() -> CFTypeID; |
| 62 |
} |