#[repr(C)]pub struct CFError { /* private fields */ }
CFError
only.Expand description
This is the type of a reference to CFErrors. CFErrorRef is toll-free bridged with NSError.
See also Apple’s documentation
Implementations§
Source§impl CFError
impl CFError
Sourcepub unsafe fn new(
allocator: Option<&CFAllocator>,
domain: Option<&CFErrorDomain>,
code: CFIndex,
user_info: Option<&CFDictionary>,
) -> Option<CFRetained<CFError>>
Available on crate feature CFDictionary
only.
pub unsafe fn new( allocator: Option<&CFAllocator>, domain: Option<&CFErrorDomain>, code: CFIndex, user_info: Option<&CFDictionary>, ) -> Option<CFRetained<CFError>>
CFDictionary
only.Creates a new CFError.
Parameter allocator
: The CFAllocator which should be used to allocate memory for the error. This parameter may be NULL in which case the
current default CFAllocator is used. If this reference is not a valid CFAllocator, the behavior is undefined.
Parameter domain
: A CFString identifying the error domain. If this reference is NULL or is otherwise not a valid CFString, the behavior is undefined.
Parameter code
: A CFIndex identifying the error code. The code is interpreted within the context of the error domain.
Parameter userInfo
: A CFDictionary created with kCFCopyStringDictionaryKeyCallBacks and kCFTypeDictionaryValueCallBacks. It will be copied with CFDictionaryCreateCopy().
If no userInfo dictionary is desired, NULL may be passed in as a convenience, in which case an empty userInfo dictionary will be assigned.
Returns: A reference to the new CFError.
Sourcepub unsafe fn with_user_info_keys_and_values(
allocator: Option<&CFAllocator>,
domain: Option<&CFErrorDomain>,
code: CFIndex,
user_info_keys: *const *const c_void,
user_info_values: *const *const c_void,
num_user_info_values: CFIndex,
) -> Option<CFRetained<CFError>>
pub unsafe fn with_user_info_keys_and_values( allocator: Option<&CFAllocator>, domain: Option<&CFErrorDomain>, code: CFIndex, user_info_keys: *const *const c_void, user_info_values: *const *const c_void, num_user_info_values: CFIndex, ) -> Option<CFRetained<CFError>>
Creates a new CFError without having to create an intermediate userInfo dictionary.
Parameter allocator
: The CFAllocator which should be used to allocate memory for the error. This parameter may be NULL in which case the
current default CFAllocator is used. If this reference is not a valid CFAllocator, the behavior is undefined.
Parameter domain
: A CFString identifying the error domain. If this reference is NULL or is otherwise not a valid CFString, the behavior is undefined.
Parameter code
: A CFIndex identifying the error code. The code is interpreted within the context of the error domain.
Parameter userInfoKeys
: An array of numUserInfoValues CFStrings used as keys in creating the userInfo dictionary. NULL is valid only if numUserInfoValues is 0.
Parameter userInfoValues
: An array of numUserInfoValues CF types used as values in creating the userInfo dictionary. NULL is valid only if numUserInfoValues is 0.
Parameter numUserInfoValues
: CFIndex representing the number of keys and values in the userInfoKeys and userInfoValues arrays.
Returns: A reference to the new CFError. numUserInfoValues CF types are gathered from each of userInfoKeys and userInfoValues to create the userInfo dictionary.
Sourcepub fn domain(self: &CFError) -> Option<CFRetained<CFErrorDomain>>
pub fn domain(self: &CFError) -> Option<CFRetained<CFErrorDomain>>
Returns the error domain the CFError was created with.
Parameter err
: The CFError whose error domain is to be returned. If this reference is not a valid CFError, the behavior is undefined.
Returns: The error domain of the CFError. Since this is a “Get” function, the caller shouldn’t CFRelease the return value.
Sourcepub fn code(self: &CFError) -> CFIndex
pub fn code(self: &CFError) -> CFIndex
Returns the error code the CFError was created with.
Parameter err
: The CFError whose error code is to be returned. If this reference is not a valid CFError, the behavior is undefined.
Returns: The error code of the CFError (not an error return for the current call).
Sourcepub fn user_info(self: &CFError) -> Option<CFRetained<CFDictionary>>
Available on crate feature CFDictionary
only.
pub fn user_info(self: &CFError) -> Option<CFRetained<CFDictionary>>
CFDictionary
only.Returns CFError userInfo dictionary.
Returns a dictionary containing the same keys and values as in the userInfo dictionary the CFError was created with. Returns an empty dictionary if NULL was supplied to CFErrorCreate().
Parameter err
: The CFError whose error user info is to be returned. If this reference is not a valid CFError, the behavior is undefined.
Returns: The user info of the CFError.
Sourcepub fn description(self: &CFError) -> Option<CFRetained<CFString>>
pub fn description(self: &CFError) -> Option<CFRetained<CFString>>
Returns a human-presentable description for the error. CFError creators should strive to make sure the return value is human-presentable and localized by providing a value for kCFErrorLocalizedDescriptionKey at the time of CFError creation.
This is a complete sentence or two which says what failed and why it failed. Please refer to header comments for -[NSError localizedDescription] for details on the steps used to compute this; but roughly:
- Use value of kCFErrorLocalizedDescriptionKey as-is if provided.
- Use value of kCFErrorLocalizedFailureKey if provided, optionally followed by kCFErrorLocalizedFailureReasonKey if available.
- Use value of kCFErrorLocalizedFailureReasonKey, combining with a generic failure message such as: “Operation code not be completed. “ + kCFErrorLocalizedFailureReasonKey.
- If all of the above fail, generate a semi-user presentable string from kCFErrorDescriptionKey, the domain, and code. Something like: “Operation could not be completed. Error domain/code occurred. “ or “Operation could not be completed. “ + kCFErrorDescriptionKey + “ (Error domain/code)” Toll-free bridged NSError instances might provide additional behaviors for manufacturing a description string. Do not count on the exact contents or format of the returned string, it might change.
Parameter err
: The CFError whose description is to be returned. If this reference is not a valid CFError, the behavior is undefined.
Returns: A CFString with human-presentable description of the CFError. Never NULL.
Sourcepub fn failure_reason(self: &CFError) -> Option<CFRetained<CFString>>
pub fn failure_reason(self: &CFError) -> Option<CFRetained<CFString>>
Returns a human-presentable failure reason for the error. May return NULL. CFError creators should strive to make sure the return value is human-presentable and localized by providing a value for kCFErrorLocalizedFailureReasonKey at the time of CFError creation.
This is a complete sentence which describes why the operation failed. In many cases this will be just the “because” part of the description (but as a complete sentence, which makes localization easier). By default this looks for kCFErrorLocalizedFailureReasonKey in the user info. Toll-free bridged NSError instances might provide additional behaviors for manufacturing this value. If no user-presentable string is available, returns NULL. Example Description: “Could not save file ‘Letter’ in folder ‘Documents’ because the volume ‘MyDisk’ doesn’t have enough space.” Corresponding FailureReason: “The volume ‘MyDisk’ doesn’t have enough space.”
Parameter err
: The CFError whose failure reason is to be returned. If this reference is not a valid CFError, the behavior is undefined.
Returns: A CFString with the localized, end-user presentable failure reason of the CFError, or NULL.
Sourcepub fn recovery_suggestion(self: &CFError) -> Option<CFRetained<CFString>>
pub fn recovery_suggestion(self: &CFError) -> Option<CFRetained<CFString>>
Returns a human presentable recovery suggestion for the error. May return NULL. CFError creators should strive to make sure the return value is human-presentable and localized by providing a value for kCFErrorLocalizedRecoverySuggestionKey at the time of CFError creation.
This is the string that can be displayed as the “informative” (aka “secondary”) message on an alert panel. By default this looks for kCFErrorLocalizedRecoverySuggestionKey in the user info. Toll-free bridged NSError instances might provide additional behaviors for manufacturing this value. If no user-presentable string is available, returns NULL. Example Description: “Could not save file ‘Letter’ in folder ‘Documents’ because the volume ‘MyDisk’ doesn’t have enough space.” Corresponding RecoverySuggestion: “Remove some files from the volume and try again.”
Parameter err
: The CFError whose recovery suggestion is to be returned. If this reference is not a valid CFError, the behavior is undefined.
Returns: A CFString with the localized, end-user presentable recovery suggestion of the CFError, or NULL.
Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T: ConcreteType>(&self) -> Option<&T>
pub fn downcast_ref<T: ConcreteType>(&self) -> Option<&T>
Attempt to downcast the type to that of type T
.
This is the reference-variant. Use CFRetained::downcast
if you
want to convert a retained type. See also ConcreteType
for more
details on which types support being converted to.
Sourcepub fn retain_count(&self) -> usize
pub fn retain_count(&self) -> usize
Get the reference count of the object.
This function may be useful for debugging. You normally do not use this function otherwise.
Beware that some things (like CFNumber
s, small CFString
s etc.) may
not have a normal retain count for optimization purposes, and can
return usize::MAX
in that case.
Trait Implementations§
Source§impl ConcreteType for CFError
impl ConcreteType for CFError
Source§impl Error for CFError
Available on crate features CFString
and std
only.
impl Error for CFError
CFString
and std
only.1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl RefEncode for CFError
impl RefEncode for CFError
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for CFError
impl Type for CFError
Source§fn retain(&self) -> CFRetained<Self> ⓘwhere
Self: Sized,
fn retain(&self) -> CFRetained<Self> ⓘwhere
Self: Sized,
Source§fn as_concrete_TypeRef(&self) -> &Self
fn as_concrete_TypeRef(&self) -> &Self
core-foundation
crate.Source§unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self> ⓘwhere
Self: Sized,
unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self> ⓘwhere
Self: Sized,
core-foundation
crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &CFType
core-foundation
crate.Source§unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self> ⓘwhere
Self: Sized,
unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self> ⓘwhere
Self: Sized,
core-foundation
crate. Read more