summaryrefslogtreecommitdiffstats
path: root/vendor/core-foundation
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/core-foundation
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/core-foundation')
-rw-r--r--vendor/core-foundation/.cargo-checksum.json2
-rw-r--r--vendor/core-foundation/Cargo.toml19
-rw-r--r--vendor/core-foundation/src/array.rs97
-rw-r--r--vendor/core-foundation/src/attributed_string.rs51
-rw-r--r--vendor/core-foundation/src/base.rs84
-rw-r--r--vendor/core-foundation/src/boolean.rs17
-rw-r--r--vendor/core-foundation/src/bundle.rs65
-rw-r--r--vendor/core-foundation/src/characterset.rs4
-rw-r--r--vendor/core-foundation/src/data.rs53
-rw-r--r--vendor/core-foundation/src/date.rs25
-rw-r--r--vendor/core-foundation/src/dictionary.rs204
-rw-r--r--vendor/core-foundation/src/error.rs15
-rw-r--r--vendor/core-foundation/src/filedescriptor.rs90
-rw-r--r--vendor/core-foundation/src/lib.rs24
-rw-r--r--vendor/core-foundation/src/mach_port.rs13
-rw-r--r--vendor/core-foundation/src/number.rs54
-rw-r--r--vendor/core-foundation/src/propertylist.rs109
-rw-r--r--vendor/core-foundation/src/runloop.rs128
-rw-r--r--vendor/core-foundation/src/set.rs32
-rw-r--r--vendor/core-foundation/src/string.rs100
-rw-r--r--vendor/core-foundation/src/timezone.rs25
-rw-r--r--vendor/core-foundation/src/url.rs75
-rw-r--r--vendor/core-foundation/src/uuid.rs32
23 files changed, 785 insertions, 533 deletions
diff --git a/vendor/core-foundation/.cargo-checksum.json b/vendor/core-foundation/.cargo-checksum.json
index 93d6c58e7..05422dac5 100644
--- a/vendor/core-foundation/.cargo-checksum.json
+++ b/vendor/core-foundation/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"5909548b679fccc46cd25a91f3784139e4e53bbed284e3b7cc72c599e599e138","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","src/array.rs":"e5e6ea11e660e5e6676568c9b5b4595633c16fad770755b13bb4fde6c7436a4e","src/attributed_string.rs":"c04c5a3c912b6ab58d3081fa5dfa8fda07957b26396ebc907bba5ad07dc1087d","src/base.rs":"9ed46d59afdb22ecc65504ccd77f1c98108ea0ff96fad568dadb7ed49fde588c","src/boolean.rs":"f5b4d295aaf6cc3681212afebeae2974c5d551125badcc066e6089ac0d2a0873","src/bundle.rs":"c290a87d8bc43d8c9e1935c18e6d7127f46fd211cc2b041ed9e7b618b9df270c","src/characterset.rs":"a3ffb46c5463c99813eebfc177a65794f44a1b9343534e28bbccd262034714c2","src/data.rs":"c8d2ec30d8ac6249ef84afa0f7638d950b5c70d687aeb4ba9e3e46806aa872aa","src/date.rs":"a02f6cca7b6e8fbabc7713177429012658dba5146556e14a08e7baaf81958d83","src/dictionary.rs":"780599de45d64e8f4bca18ad50fc4a909f6e9aab1c3f2cea451f469d766f6782","src/error.rs":"22c21087d9c2c103d1bcb2c4af33b684317bbda5d4747902e510d410f8c1a14b","src/filedescriptor.rs":"022463c6dce8823231dc88064e5d9cffb494b410391388fe1feb50d3419d98b7","src/lib.rs":"2d0b007b264642cbad31e8c901f5f2235ed55515ef73e573a8d86306a7cd4f06","src/mach_port.rs":"87aa8dd28060bbb976197e7cc981eb733762b9bcc29eddd742f44aa8141e71b1","src/number.rs":"5a6cc9036c156e7e9d787864dd671087677abf4175cd840cbf123ccd89abcafe","src/propertylist.rs":"3c964d976709562b96f391265130c0f8fced307267a2b6385bab469048518b55","src/runloop.rs":"514a8ea7b185812fbb6d4835b0f7d26208f3121dadf1553a3a39c5013f2820af","src/set.rs":"da75b31f894bd04c0518211e113ca21a2781cd6ac71018104eeb354dd2f1a19e","src/string.rs":"bea7f3fd2528377442d1bebfeacf7e905d879320ae662fe6a8ef917b6a8e9c36","src/timezone.rs":"6dcf188db76303292b519d6283b71b71c7b3d6ed1afddc28de16d727075f5ef1","src/url.rs":"c544725399d3fbc4de54fd9d1c987e02f81760effd08c5c64c8deacd11478950","src/uuid.rs":"c3457e43fc22ba0f3fcab3ee8108500585ba005dbcbfa7edad0d389701ddf379","tests/use_macro_outside_crate.rs":"ed5e74ac9e988f2609c0b785189f1e6368d693f6401603ad065521f3ab51df94"},"package":"194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"} \ No newline at end of file
+{"files":{"Cargo.toml":"2e85272c5cffb75aadcbb83d8ca1a619af3ccb9d810c1e07349f3b618fa05b7e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","src/array.rs":"1ec64187ec7c3ff0a9cf9739fb83d1f0b6141d827e4f21a14203b7058ca12056","src/attributed_string.rs":"7c129d266872bf9e0f8cbd9477d8cc27405b806395e59e1647bedf9af06f8949","src/base.rs":"7ec2afcbc200aabaa01687efce2eb27c9effc9eae64d3c579827de731fbd290e","src/boolean.rs":"60aef5be531e867f03524c32a88609100d07d9166184545feab760af9eb3d7ec","src/bundle.rs":"00f7ae30df3cc59079e771da0eda2b1972f52b13cc7bd95ae48b0e9bd1836ff4","src/characterset.rs":"126884d51e75db5be4cb2988f4e97e0e1b592c900e0158082d8c0dda7a453b0f","src/data.rs":"bfaa4427b6bc4c838188506ee154622983bbfcc10641be3f58525b89a854d4cd","src/date.rs":"d1ec3f918cf6c62d0e36d50d495c125d275a9a89442a740eea5d41dcc71a96fa","src/dictionary.rs":"f6d73c08fa9afd30d1df70cceea55dd30c7b81b8a78117d8843f1b3390051dca","src/error.rs":"433982fb7b421f5bf386d7eba22a7ffb8673486bb6455ff3fa30c875b064f718","src/filedescriptor.rs":"d3ece69ff461b215f7ff98dc6139723c4a5a53849a9747cccd24e72c185c4ffd","src/lib.rs":"92502d5f7d0e2ba266ec3531c01dd996e1832f1e6e9e66b10596e6fb870480cb","src/mach_port.rs":"e5400039696a70bdc0e6e14b1a68c493b741136945ce0eb67208cd4d0f895e1b","src/number.rs":"48e2efe219a7eaa4bc7bc3a48fa45f32fbbfd6363620838fef16a98b86e05061","src/propertylist.rs":"23e9a42d506983374d0c3439ab80407bbd472a3487812693a411597ff5eb1bd8","src/runloop.rs":"ff5bbb8a145befa7f244d937161d87f059ea60c9c482ab32e845222ee6fabf34","src/set.rs":"39e41a3d4f9e4dd50864a9c3581508e1b09549dc89d57fa84935964d98469bad","src/string.rs":"3b25b169d0f18dae66e6f123a116a04c79096f9e44e4221d4dbdcea4e152355c","src/timezone.rs":"7b8e46bde9e8aa71a906ab26b8ff7b6251568ebf210bab10d11c6ba0ce64ecd5","src/url.rs":"dc125dd95e9b8386770b89f5437ab904ceff0843e1bf820f548bddfc31e1c40c","src/uuid.rs":"e290c592871b7cea6ec09d2b3e34ec9033968dda725cf49e410535f79d2b41f8","tests/use_macro_outside_crate.rs":"ed5e74ac9e988f2609c0b785189f1e6368d693f6401603ad065521f3ab51df94"},"package":"91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"} \ No newline at end of file
diff --git a/vendor/core-foundation/Cargo.toml b/vendor/core-foundation/Cargo.toml
index 7ea957815..47cf3f264 100644
--- a/vendor/core-foundation/Cargo.toml
+++ b/vendor/core-foundation/Cargo.toml
@@ -10,23 +10,32 @@
# See Cargo.toml.orig for the original contents.
[package]
+edition = "2018"
name = "core-foundation"
-version = "0.9.3"
+version = "0.9.4"
authors = ["The Servo Project Developers"]
description = "Bindings to Core Foundation for macOS"
homepage = "https://github.com/servo/core-foundation-rs"
-keywords = ["macos", "framework", "objc"]
+keywords = [
+ "macos",
+ "framework",
+ "objc",
+]
categories = ["os::macos-apis"]
-license = "MIT / Apache-2.0"
+license = "MIT OR Apache-2.0"
repository = "https://github.com/servo/core-foundation-rs"
+
[package.metadata.docs.rs]
+all-features = true
default-target = "x86_64-apple-darwin"
+
[dependencies.chrono]
version = "0.4"
optional = true
[dependencies.core-foundation-sys]
-version = "0.8.3"
+version = "0.8.6"
+default-features = false
[dependencies.libc]
version = "0.2"
@@ -36,6 +45,8 @@ version = "0.5"
optional = true
[features]
+default = ["link"]
+link = ["core-foundation-sys/link"]
mac_os_10_7_support = ["core-foundation-sys/mac_os_10_7_support"]
mac_os_10_8_features = ["core-foundation-sys/mac_os_10_8_features"]
with-chrono = ["chrono"]
diff --git a/vendor/core-foundation/src/array.rs b/vendor/core-foundation/src/array.rs
index d66ffc5b8..b6f5d5c74 100644
--- a/vendor/core-foundation/src/array.rs
+++ b/vendor/core-foundation/src/array.rs
@@ -9,17 +9,17 @@
//! Heterogeneous immutable arrays.
+use crate::ConcreteCFType;
pub use core_foundation_sys::array::*;
pub use core_foundation_sys::base::CFIndex;
-use core_foundation_sys::base::{CFTypeRef, CFRelease, kCFAllocatorDefault};
-use std::mem;
+use core_foundation_sys::base::{kCFAllocatorDefault, CFRelease, CFTypeRef};
use std::marker::PhantomData;
+use std::mem;
use std::os::raw::c_void;
use std::ptr;
-use ConcreteCFType;
-use base::{CFIndexConvertible, TCFType, CFRange};
-use base::{FromVoid, ItemRef};
+use crate::base::{CFIndexConvertible, CFRange, TCFType};
+use crate::base::{FromVoid, ItemRef};
/// A heterogeneous immutable array.
pub struct CFArray<T = *const c_void>(CFArrayRef, PhantomData<T>);
@@ -63,24 +63,34 @@ unsafe impl ConcreteCFType for CFArray<*const c_void> {}
impl<T> CFArray<T> {
/// Creates a new `CFArray` with the given elements, which must implement `Copy`.
- pub fn from_copyable(elems: &[T]) -> CFArray<T> where T: Copy {
+ pub fn from_copyable(elems: &[T]) -> CFArray<T>
+ where
+ T: Copy,
+ {
unsafe {
- let array_ref = CFArrayCreate(kCFAllocatorDefault,
- elems.as_ptr() as *const *const c_void,
- elems.len().to_CFIndex(),
- ptr::null());
+ let array_ref = CFArrayCreate(
+ kCFAllocatorDefault,
+ elems.as_ptr() as *const *const c_void,
+ elems.len().to_CFIndex(),
+ ptr::null(),
+ );
TCFType::wrap_under_create_rule(array_ref)
}
}
/// Creates a new `CFArray` with the given elements, which must be `CFType` objects.
- pub fn from_CFTypes(elems: &[T]) -> CFArray<T> where T: TCFType {
+ pub fn from_CFTypes(elems: &[T]) -> CFArray<T>
+ where
+ T: TCFType,
+ {
unsafe {
let elems: Vec<CFTypeRef> = elems.iter().map(|elem| elem.as_CFTypeRef()).collect();
- let array_ref = CFArrayCreate(kCFAllocatorDefault,
- elems.as_ptr(),
- elems.len().to_CFIndex(),
- &kCFTypeArrayCallBacks);
+ let array_ref = CFArrayCreate(
+ kCFAllocatorDefault,
+ elems.as_ptr(),
+ elems.len().to_CFIndex(),
+ &kCFTypeArrayCallBacks,
+ );
TCFType::wrap_under_create_rule(array_ref)
}
}
@@ -105,7 +115,7 @@ impl<T> CFArray<T> {
/// Core Foundation objects (not always true), they need to be wrapped with
/// `TCFType::wrap_under_get_rule()`.
#[inline]
- pub fn iter<'a>(&'a self) -> CFArrayIterator<'a, T> {
+ pub fn iter(&self) -> CFArrayIterator<'_, T> {
CFArrayIterator {
array: self,
index: 0,
@@ -115,20 +125,30 @@ impl<T> CFArray<T> {
#[inline]
pub fn len(&self) -> CFIndex {
- unsafe {
- CFArrayGetCount(self.0)
- }
+ unsafe { CFArrayGetCount(self.0) }
}
+ /// Returns `true` if the array contains no elements.
#[inline]
- pub unsafe fn get_unchecked<'a>(&'a self, index: CFIndex) -> ItemRef<'a, T> where T: FromVoid {
+ pub fn is_empty(&self) -> bool {
+ self.len() == 0
+ }
+
+ #[inline]
+ pub unsafe fn get_unchecked(&self, index: CFIndex) -> ItemRef<'_, T>
+ where
+ T: FromVoid,
+ {
T::from_void(CFArrayGetValueAtIndex(self.0, index))
}
#[inline]
- pub fn get<'a>(&'a self, index: CFIndex) -> Option<ItemRef<'a, T>> where T: FromVoid {
+ pub fn get(&self, index: CFIndex) -> Option<ItemRef<'_, T>>
+ where
+ T: FromVoid,
+ {
if index < self.len() {
- Some(unsafe { T::from_void(CFArrayGetValueAtIndex(self.0, index)) } )
+ Some(unsafe { T::from_void(CFArrayGetValueAtIndex(self.0, index)) })
} else {
None
}
@@ -146,7 +166,7 @@ impl<T> CFArray<T> {
pub fn get_all_values(&self) -> Vec<*const c_void> {
self.get_values(CFRange {
location: 0,
- length: self.len()
+ length: self.len(),
})
}
}
@@ -162,13 +182,15 @@ impl<'a, T: FromVoid> IntoIterator for &'a CFArray<T> {
#[cfg(test)]
mod tests {
+ use crate::number::CFNumber;
+
use super::*;
+ use crate::base::CFType;
use std::mem;
- use base::CFType;
#[test]
fn to_untyped_correct_retain_count() {
- let array = CFArray::<CFType>::from_CFTypes(&[]);
+ let array = CFArray::<CFType>::from_CFTypes(&[CFNumber::from(4).as_CFType()]);
assert_eq!(array.retain_count(), 1);
let untyped_array = array.to_untyped();
@@ -181,7 +203,7 @@ mod tests {
#[test]
fn into_untyped() {
- let array = CFArray::<CFType>::from_CFTypes(&[]);
+ let array = CFArray::<CFType>::from_CFTypes(&[CFNumber::from(4).as_CFType()]);
let array2 = array.to_untyped();
assert_eq!(array.retain_count(), 2);
@@ -194,9 +216,9 @@ mod tests {
#[test]
fn borrow() {
- use string::CFString;
+ use crate::string::CFString;
- let string = CFString::from_static_string("bar");
+ let string = CFString::from_static_string("alongerstring");
assert_eq!(string.retain_count(), 1);
let x;
{
@@ -208,7 +230,7 @@ mod tests {
{
x = arr.get(0).unwrap().clone();
assert_eq!(x.retain_count(), 2);
- assert_eq!(x.to_string(), "bar");
+ assert_eq!(x.to_string(), "alongerstring");
}
}
assert_eq!(x.retain_count(), 1);
@@ -216,23 +238,24 @@ mod tests {
#[test]
fn iter_untyped_array() {
- use string::{CFString, CFStringRef};
- use base::TCFTypeRef;
+ use crate::base::TCFTypeRef;
+ use crate::string::{CFString, CFStringRef};
- let cf_string = CFString::from_static_string("bar");
+ let cf_string = CFString::from_static_string("alongerstring");
let array: CFArray = CFArray::from_CFTypes(&[cf_string.clone()]).into_untyped();
- let cf_strings = array.iter().map(|ptr| {
- unsafe { CFString::wrap_under_get_rule(CFStringRef::from_void_ptr(*ptr)) }
- }).collect::<Vec<_>>();
+ let cf_strings = array
+ .iter()
+ .map(|ptr| unsafe { CFString::wrap_under_get_rule(CFStringRef::from_void_ptr(*ptr)) })
+ .collect::<Vec<_>>();
let strings = cf_strings.iter().map(|s| s.to_string()).collect::<Vec<_>>();
assert_eq!(cf_string.retain_count(), 3);
- assert_eq!(&strings[..], &["bar"]);
+ assert_eq!(&strings[..], &["alongerstring"]);
}
#[test]
fn should_box_and_unbox() {
- use number::CFNumber;
+ use crate::number::CFNumber;
let n0 = CFNumber::from(0);
let n1 = CFNumber::from(1);
diff --git a/vendor/core-foundation/src/attributed_string.rs b/vendor/core-foundation/src/attributed_string.rs
index d4a467946..6a2b349f1 100644
--- a/vendor/core-foundation/src/attributed_string.rs
+++ b/vendor/core-foundation/src/attributed_string.rs
@@ -9,22 +9,26 @@
pub use core_foundation_sys::attributed_string::*;
-use base::TCFType;
-use core_foundation_sys::base::{CFIndex, CFRange, kCFAllocatorDefault};
+use crate::base::TCFType;
+use crate::string::{CFString, CFStringRef};
+use core_foundation_sys::base::{kCFAllocatorDefault, CFIndex, CFRange};
use std::ptr::null;
-use string::{CFString, CFStringRef};
-declare_TCFType!{
+declare_TCFType! {
CFAttributedString, CFAttributedStringRef
}
-impl_TCFType!(CFAttributedString, CFAttributedStringRef, CFAttributedStringGetTypeID);
+impl_TCFType!(
+ CFAttributedString,
+ CFAttributedStringRef,
+ CFAttributedStringGetTypeID
+);
impl CFAttributedString {
#[inline]
pub fn new(string: &CFString) -> Self {
unsafe {
- let astr_ref = CFAttributedStringCreate(
- kCFAllocatorDefault, string.as_concrete_TypeRef(), null());
+ let astr_ref =
+ CFAttributedStringCreate(kCFAllocatorDefault, string.as_concrete_TypeRef(), null());
CFAttributedString::wrap_under_create_rule(astr_ref)
}
@@ -32,23 +36,24 @@ impl CFAttributedString {
#[inline]
pub fn char_len(&self) -> CFIndex {
- unsafe {
- CFAttributedStringGetLength(self.0)
- }
+ unsafe { CFAttributedStringGetLength(self.0) }
}
}
-declare_TCFType!{
+declare_TCFType! {
CFMutableAttributedString, CFMutableAttributedStringRef
}
-impl_TCFType!(CFMutableAttributedString, CFMutableAttributedStringRef, CFAttributedStringGetTypeID);
+impl_TCFType!(
+ CFMutableAttributedString,
+ CFMutableAttributedStringRef,
+ CFAttributedStringGetTypeID
+);
impl CFMutableAttributedString {
#[inline]
pub fn new() -> Self {
unsafe {
- let astr_ref = CFAttributedStringCreateMutable(
- kCFAllocatorDefault, 0);
+ let astr_ref = CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);
CFMutableAttributedString::wrap_under_create_rule(astr_ref)
}
@@ -56,24 +61,20 @@ impl CFMutableAttributedString {
#[inline]
pub fn char_len(&self) -> CFIndex {
- unsafe {
- CFAttributedStringGetLength(self.0)
- }
+ unsafe { CFAttributedStringGetLength(self.0) }
}
#[inline]
pub fn replace_str(&mut self, string: &CFString, range: CFRange) {
unsafe {
- CFAttributedStringReplaceString(
- self.0, range, string.as_concrete_TypeRef());
+ CFAttributedStringReplaceString(self.0, range, string.as_concrete_TypeRef());
}
}
#[inline]
pub fn set_attribute<T: TCFType>(&mut self, range: CFRange, name: CFStringRef, value: &T) {
unsafe {
- CFAttributedStringSetAttribute(
- self.0, range, name, value.as_CFTypeRef());
+ CFAttributedStringSetAttribute(self.0, range, name, value.as_CFTypeRef());
}
}
}
@@ -84,7 +85,6 @@ impl Default for CFMutableAttributedString {
}
}
-
#[cfg(test)]
mod tests {
use super::*;
@@ -93,6 +93,9 @@ mod tests {
fn attributed_string_type_id_comparison() {
// CFMutableAttributedString TypeID must be equal to CFAttributedString TypeID.
// Compilation must not fail.
- assert_eq!(<CFAttributedString as TCFType>::type_id(), <CFMutableAttributedString as TCFType>::type_id());
+ assert_eq!(
+ <CFAttributedString as TCFType>::type_id(),
+ <CFMutableAttributedString as TCFType>::type_id()
+ );
}
-} \ No newline at end of file
+}
diff --git a/vendor/core-foundation/src/base.rs b/vendor/core-foundation/src/base.rs
index f08f2b2e8..b44c1262a 100644
--- a/vendor/core-foundation/src/base.rs
+++ b/vendor/core-foundation/src/base.rs
@@ -17,8 +17,8 @@ use std::os::raw::c_void;
pub use core_foundation_sys::base::*;
-use string::CFString;
-use ConcreteCFType;
+use crate::string::CFString;
+use crate::ConcreteCFType;
pub trait CFIndexConvertible {
/// Always use this method to construct a `CFIndex` value. It performs bounds checking to
@@ -37,7 +37,7 @@ impl CFIndexConvertible for usize {
}
}
-declare_TCFType!{
+declare_TCFType! {
/// Superclass of all Core Foundation objects.
CFType, CFTypeRef
}
@@ -111,13 +111,11 @@ impl CFType {
}
impl fmt::Debug for CFType {
- /// Formats the value using [`CFCopyDescription`].
- ///
- /// [`CFCopyDescription`]: https://developer.apple.com/documentation/corefoundation/1521252-cfcopydescription?language=objc
+ /// Formats the value using [`CFCopyDescription`].
+ ///
+ /// [`CFCopyDescription`]: https://developer.apple.com/documentation/corefoundation/1521252-cfcopydescription?language=objc
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- let desc = unsafe {
- CFString::wrap_under_create_rule(CFCopyDescription(self.0))
- };
+ let desc = unsafe { CFString::wrap_under_create_rule(CFCopyDescription(self.0)) };
desc.fmt(f)
}
}
@@ -125,18 +123,14 @@ impl fmt::Debug for CFType {
impl Clone for CFType {
#[inline]
fn clone(&self) -> CFType {
- unsafe {
- TCFType::wrap_under_get_rule(self.0)
- }
+ unsafe { TCFType::wrap_under_get_rule(self.0) }
}
}
impl PartialEq for CFType {
#[inline]
fn eq(&self, other: &CFType) -> bool {
- unsafe {
- CFEqual(self.as_CFTypeRef(), other.as_CFTypeRef()) != 0
- }
+ unsafe { CFEqual(self.as_CFTypeRef(), other.as_CFTypeRef()) != 0 }
}
}
@@ -153,7 +147,6 @@ impl CFAllocator {
}
}
-
/// All Core Foundation types implement this trait. The associated type `Ref` specifies the
/// associated Core Foundation type: e.g. for `CFType` this is `CFTypeRef`; for `CFArray` this is
/// `CFArrayRef`.
@@ -165,7 +158,7 @@ pub trait TCFType {
/// The reference type wrapped inside this type.
type Ref: TCFTypeRef;
- /// Returns the object as its concrete TypeRef.
+ /// Returns the object as its concrete `TypeRef`.
fn as_concrete_TypeRef(&self) -> Self::Ref;
/// Returns an instance of the object, wrapping the underlying `CFTypeRef` subclass. Use this
@@ -178,9 +171,7 @@ pub trait TCFType {
/// Returns the object as a wrapped `CFType`. The reference count is incremented by one.
#[inline]
fn as_CFType(&self) -> CFType {
- unsafe {
- TCFType::wrap_under_get_rule(self.as_CFTypeRef())
- }
+ unsafe { TCFType::wrap_under_get_rule(self.as_CFTypeRef()) }
}
/// Returns the object as a wrapped `CFType`. Consumes self and avoids changing the reference
@@ -206,27 +197,21 @@ pub trait TCFType {
/// whether the return value of this method is greater than zero.
#[inline]
fn retain_count(&self) -> CFIndex {
- unsafe {
- CFGetRetainCount(self.as_CFTypeRef())
- }
+ unsafe { CFGetRetainCount(self.as_CFTypeRef()) }
}
/// Returns the type ID of this object.
#[inline]
fn type_of(&self) -> CFTypeID {
- unsafe {
- CFGetTypeID(self.as_CFTypeRef())
- }
+ unsafe { CFGetTypeID(self.as_CFTypeRef()) }
}
/// Writes a debugging version of this object on standard error.
fn show(&self) {
- unsafe {
- CFShow(self.as_CFTypeRef())
- }
+ unsafe { CFShow(self.as_CFTypeRef()) }
}
- /// Returns true if this value is an instance of another type.
+ /// Returns `true` if this value is an instance of another type.
#[inline]
fn instance_of<OtherCFType: TCFType>(&self) -> bool {
self.type_of() == OtherCFType::type_id()
@@ -318,9 +303,11 @@ impl<'a, T: PartialEq> PartialEq for ItemMutRef<'a, T> {
}
}
-/// A trait describing how to convert from the stored *mut c_void to the desired T
+/// A trait describing how to convert from the stored `*mut c_void` to the desired `T`
pub unsafe trait FromMutVoid {
- unsafe fn from_mut_void<'a>(x: *mut c_void) -> ItemMutRef<'a, Self> where Self: std::marker::Sized;
+ unsafe fn from_mut_void<'a>(x: *mut c_void) -> ItemMutRef<'a, Self>
+ where
+ Self: std::marker::Sized;
}
unsafe impl FromMutVoid for u32 {
@@ -337,13 +324,18 @@ unsafe impl FromMutVoid for *const c_void {
unsafe impl<T: TCFType> FromMutVoid for T {
unsafe fn from_mut_void<'a>(x: *mut c_void) -> ItemMutRef<'a, Self> {
- ItemMutRef(ManuallyDrop::new(TCFType::wrap_under_create_rule(T::Ref::from_void_ptr(x))), PhantomData)
+ ItemMutRef(
+ ManuallyDrop::new(TCFType::wrap_under_create_rule(T::Ref::from_void_ptr(x))),
+ PhantomData,
+ )
}
}
-/// A trait describing how to convert from the stored *const c_void to the desired T
+/// A trait describing how to convert from the stored `*const c_void` to the desired `T`
pub unsafe trait FromVoid {
- unsafe fn from_void<'a>(x: *const c_void) -> ItemRef<'a, Self> where Self: std::marker::Sized;
+ unsafe fn from_void<'a>(x: *const c_void) -> ItemRef<'a, Self>
+ where
+ Self: std::marker::Sized;
}
unsafe impl FromVoid for u32 {
@@ -362,11 +354,14 @@ unsafe impl FromVoid for *const c_void {
unsafe impl<T: TCFType> FromVoid for T {
unsafe fn from_void<'a>(x: *const c_void) -> ItemRef<'a, Self> {
- ItemRef(ManuallyDrop::new(TCFType::wrap_under_create_rule(T::Ref::from_void_ptr(x))), PhantomData)
+ ItemRef(
+ ManuallyDrop::new(TCFType::wrap_under_create_rule(T::Ref::from_void_ptr(x))),
+ PhantomData,
+ )
}
}
-/// A trait describing how to convert from the stored *const c_void to the desired T
+/// A trait describing how to convert from the stored `*const c_void` to the desired `T`
pub unsafe trait ToVoid<T> {
fn to_void(&self) -> *const c_void;
}
@@ -395,12 +390,11 @@ unsafe impl ToVoid<CFType> for CFTypeRef {
}
}
-
#[cfg(test)]
mod tests {
use super::*;
+ use crate::boolean::CFBoolean;
use std::mem;
- use boolean::CFBoolean;
#[test]
fn cftype_instance_of() {
@@ -413,7 +407,7 @@ mod tests {
#[test]
fn as_cftype_retain_count() {
- let string = CFString::from_static_string("bar");
+ let string = CFString::from_static_string("alongerstring");
assert_eq!(string.retain_count(), 1);
let cftype = string.as_CFType();
assert_eq!(cftype.retain_count(), 2);
@@ -423,7 +417,7 @@ mod tests {
#[test]
fn into_cftype_retain_count() {
- let string = CFString::from_static_string("bar");
+ let string = CFString::from_static_string("alongerstring");
assert_eq!(string.retain_count(), 1);
let cftype = string.into_CFType();
assert_eq!(cftype.retain_count(), 1);
@@ -431,10 +425,10 @@ mod tests {
#[test]
fn as_cftype_and_downcast() {
- let string = CFString::from_static_string("bar");
+ let string = CFString::from_static_string("alongerstring");
let cftype = string.as_CFType();
let string2 = cftype.downcast::<CFString>().unwrap();
- assert_eq!(string2.to_string(), "bar");
+ assert_eq!(string2.to_string(), "alongerstring");
assert_eq!(string.retain_count(), 3);
assert_eq!(cftype.retain_count(), 3);
@@ -443,10 +437,10 @@ mod tests {
#[test]
fn into_cftype_and_downcast_into() {
- let string = CFString::from_static_string("bar");
+ let string = CFString::from_static_string("alongerstring");
let cftype = string.into_CFType();
let string2 = cftype.downcast_into::<CFString>().unwrap();
- assert_eq!(string2.to_string(), "bar");
+ assert_eq!(string2.to_string(), "alongerstring");
assert_eq!(string2.retain_count(), 1);
}
}
diff --git a/vendor/core-foundation/src/boolean.rs b/vendor/core-foundation/src/boolean.rs
index 8c13b907d..e0e2ff762 100644
--- a/vendor/core-foundation/src/boolean.rs
+++ b/vendor/core-foundation/src/boolean.rs
@@ -9,12 +9,13 @@
//! A Boolean type.
-pub use core_foundation_sys::number::{CFBooleanRef, CFBooleanGetTypeID, kCFBooleanTrue, kCFBooleanFalse};
+pub use core_foundation_sys::number::{
+ kCFBooleanFalse, kCFBooleanTrue, CFBooleanGetTypeID, CFBooleanRef,
+};
-use base::TCFType;
+use crate::base::TCFType;
-
-declare_TCFType!{
+declare_TCFType! {
/// A Boolean type.
///
/// FIXME(pcwalton): Should be a newtype struct, but that fails due to a Rust compiler bug.
@@ -25,15 +26,11 @@ impl_CFTypeDescription!(CFBoolean);
impl CFBoolean {
pub fn true_value() -> CFBoolean {
- unsafe {
- TCFType::wrap_under_get_rule(kCFBooleanTrue)
- }
+ unsafe { TCFType::wrap_under_get_rule(kCFBooleanTrue) }
}
pub fn false_value() -> CFBoolean {
- unsafe {
- TCFType::wrap_under_get_rule(kCFBooleanFalse)
- }
+ unsafe { TCFType::wrap_under_get_rule(kCFBooleanFalse) }
}
}
diff --git a/vendor/core-foundation/src/bundle.rs b/vendor/core-foundation/src/bundle.rs
index b9ab1f65f..f6d53a991 100644
--- a/vendor/core-foundation/src/bundle.rs
+++ b/vendor/core-foundation/src/bundle.rs
@@ -14,13 +14,13 @@ pub use core_foundation_sys::bundle::*;
use core_foundation_sys::url::kCFURLPOSIXPathStyle;
use std::path::PathBuf;
-use base::{CFType, TCFType};
-use url::CFURL;
-use dictionary::CFDictionary;
+use crate::base::{CFType, TCFType};
+use crate::dictionary::CFDictionary;
+use crate::string::CFString;
+use crate::url::CFURL;
use std::os::raw::c_void;
-use string::CFString;
-declare_TCFType!{
+declare_TCFType! {
/// A Bundle type.
CFBundle, CFBundleRef
}
@@ -51,8 +51,10 @@ impl CFBundle {
pub fn function_pointer_for_name(&self, function_name: CFString) -> *const c_void {
unsafe {
- CFBundleGetFunctionPointerForName(self.as_concrete_TypeRef(),
- function_name.as_concrete_TypeRef())
+ CFBundleGetFunctionPointerForName(
+ self.as_concrete_TypeRef(),
+ function_name.as_concrete_TypeRef(),
+ )
}
}
@@ -96,7 +98,9 @@ impl CFBundle {
/// Bundle's own location
pub fn path(&self) -> Option<PathBuf> {
let url = self.bundle_url()?;
- Some(PathBuf::from(url.get_file_system_path(kCFURLPOSIXPathStyle).to_string()))
+ Some(PathBuf::from(
+ url.get_file_system_path(kCFURLPOSIXPathStyle).to_string(),
+ ))
}
/// Bundle's resources location
@@ -114,7 +118,9 @@ impl CFBundle {
/// Bundle's resources location
pub fn resources_path(&self) -> Option<PathBuf> {
let url = self.bundle_resources_url()?;
- Some(PathBuf::from(url.get_file_system_path(kCFURLPOSIXPathStyle).to_string()))
+ Some(PathBuf::from(
+ url.get_file_system_path(kCFURLPOSIXPathStyle).to_string(),
+ ))
}
pub fn private_frameworks_url(&self) -> Option<CFURL> {
@@ -140,11 +146,10 @@ impl CFBundle {
}
}
-
#[test]
fn safari_executable_url() {
- use string::CFString;
- use url::{CFURL, kCFURLPOSIXPathStyle};
+ use crate::string::CFString;
+ use crate::url::{kCFURLPOSIXPathStyle, CFURL};
let cfstr_path = CFString::from_static_string("/Applications/Safari.app");
let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true);
@@ -152,18 +157,20 @@ fn safari_executable_url() {
.expect("Safari not present")
.executable_url();
assert!(cfurl_executable.is_some());
- assert_eq!(cfurl_executable
- .unwrap()
- .absolute()
- .get_file_system_path(kCFURLPOSIXPathStyle)
- .to_string(),
- "/Applications/Safari.app/Contents/MacOS/Safari");
+ assert_eq!(
+ cfurl_executable
+ .unwrap()
+ .absolute()
+ .get_file_system_path(kCFURLPOSIXPathStyle)
+ .to_string(),
+ "/Applications/Safari.app/Contents/MacOS/Safari"
+ );
}
#[test]
fn safari_private_frameworks_url() {
- use string::CFString;
- use url::{CFURL, kCFURLPOSIXPathStyle};
+ use crate::string::CFString;
+ use crate::url::{kCFURLPOSIXPathStyle, CFURL};
let cfstr_path = CFString::from_static_string("/Applications/Safari.app");
let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true);
@@ -171,18 +178,20 @@ fn safari_private_frameworks_url() {
.expect("Safari not present")
.private_frameworks_url();
assert!(cfurl_executable.is_some());
- assert_eq!(cfurl_executable
- .unwrap()
- .absolute()
- .get_file_system_path(kCFURLPOSIXPathStyle)
- .to_string(),
- "/Applications/Safari.app/Contents/Frameworks");
+ assert_eq!(
+ cfurl_executable
+ .unwrap()
+ .absolute()
+ .get_file_system_path(kCFURLPOSIXPathStyle)
+ .to_string(),
+ "/Applications/Safari.app/Contents/Frameworks"
+ );
}
#[test]
fn non_existant_bundle() {
- use string::CFString;
- use url::{CFURL, kCFURLPOSIXPathStyle};
+ use crate::string::CFString;
+ use crate::url::{kCFURLPOSIXPathStyle, CFURL};
let cfstr_path = CFString::from_static_string("/usr/local/foo");
let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true);
diff --git a/vendor/core-foundation/src/characterset.rs b/vendor/core-foundation/src/characterset.rs
index d1b9439d6..2a05a931d 100644
--- a/vendor/core-foundation/src/characterset.rs
+++ b/vendor/core-foundation/src/characterset.rs
@@ -11,9 +11,9 @@
pub use core_foundation_sys::characterset::*;
-use base::TCFType;
+use crate::base::TCFType;
-declare_TCFType!{
+declare_TCFType! {
/// An immutable set of Unicde characters.
CFCharacterSet, CFCharacterSetRef
}
diff --git a/vendor/core-foundation/src/data.rs b/vendor/core-foundation/src/data.rs
index c510c7434..9f952199a 100644
--- a/vendor/core-foundation/src/data.rs
+++ b/vendor/core-foundation/src/data.rs
@@ -9,18 +9,16 @@
//! Core Foundation byte buffers.
-pub use core_foundation_sys::data::*;
+use core_foundation_sys::base::kCFAllocatorDefault;
use core_foundation_sys::base::CFIndex;
-use core_foundation_sys::base::{kCFAllocatorDefault};
+pub use core_foundation_sys::data::*;
use std::ops::Deref;
use std::slice;
use std::sync::Arc;
+use crate::base::{CFIndexConvertible, TCFType};
-use base::{CFIndexConvertible, TCFType};
-
-
-declare_TCFType!{
+declare_TCFType! {
/// A byte buffer.
CFData, CFDataRef
}
@@ -28,20 +26,22 @@ impl_TCFType!(CFData, CFDataRef, CFDataGetTypeID);
impl_CFTypeDescription!(CFData);
impl CFData {
- /// Creates a CFData around a copy `buffer`
+ /// Creates a [`CFData`] around a copy `buffer`
pub fn from_buffer(buffer: &[u8]) -> CFData {
unsafe {
- let data_ref = CFDataCreate(kCFAllocatorDefault,
- buffer.as_ptr(),
- buffer.len().to_CFIndex());
+ let data_ref = CFDataCreate(
+ kCFAllocatorDefault,
+ buffer.as_ptr(),
+ buffer.len().to_CFIndex(),
+ );
TCFType::wrap_under_create_rule(data_ref)
}
}
- /// Creates a CFData referencing `buffer` without creating a copy
+ /// Creates a [`CFData`] referencing `buffer` without creating a copy
pub fn from_arc<T: AsRef<[u8]> + Sync + Send>(buffer: Arc<T>) -> Self {
- use std::os::raw::c_void;
use crate::base::{CFAllocator, CFAllocatorContext};
+ use std::os::raw::c_void;
unsafe {
let ptr = (*buffer).as_ref().as_ptr() as *const _;
@@ -67,8 +67,12 @@ impl CFData {
deallocate: Some(deallocate::<T>),
preferredSize: None,
});
- let data_ref =
- CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, ptr, len, allocator.as_CFTypeRef());
+ let data_ref = CFDataCreateWithBytesNoCopy(
+ kCFAllocatorDefault,
+ ptr,
+ len,
+ allocator.as_CFTypeRef(),
+ );
TCFType::wrap_under_create_rule(data_ref)
}
}
@@ -76,18 +80,20 @@ impl CFData {
/// Returns a pointer to the underlying bytes in this data. Note that this byte buffer is
/// read-only.
#[inline]
- pub fn bytes<'a>(&'a self) -> &'a [u8] {
- unsafe {
- slice::from_raw_parts(CFDataGetBytePtr(self.0), self.len() as usize)
- }
+ pub fn bytes(&self) -> &[u8] {
+ unsafe { slice::from_raw_parts(CFDataGetBytePtr(self.0), self.len() as usize) }
}
/// Returns the length of this byte buffer.
#[inline]
pub fn len(&self) -> CFIndex {
- unsafe {
- CFDataGetLength(self.0)
- }
+ unsafe { CFDataGetLength(self.0) }
+ }
+
+ /// Returns `true` if this byte buffer is empty.
+ #[inline]
+ pub fn is_empty(&self) -> bool {
+ self.len() == 0
}
}
@@ -133,7 +139,10 @@ mod test {
}
let dropped = Arc::new(AtomicBool::default());
- let l = Arc::new(VecWrapper {inner: vec![5], dropped: dropped.clone() });
+ let l = Arc::new(VecWrapper {
+ inner: vec![5],
+ dropped: dropped.clone(),
+ });
let m = l.clone();
let dp = CFData::from_arc(l);
drop(m);
diff --git a/vendor/core-foundation/src/date.rs b/vendor/core-foundation/src/date.rs
index 57ee7211e..c27bad25d 100644
--- a/vendor/core-foundation/src/date.rs
+++ b/vendor/core-foundation/src/date.rs
@@ -9,16 +9,15 @@
//! Core Foundation date objects.
-pub use core_foundation_sys::date::*;
use core_foundation_sys::base::kCFAllocatorDefault;
+pub use core_foundation_sys::date::*;
-use base::TCFType;
+use crate::base::TCFType;
#[cfg(feature = "with-chrono")]
use chrono::NaiveDateTime;
-
-declare_TCFType!{
+declare_TCFType! {
/// A date.
CFDate, CFDateRef
}
@@ -42,16 +41,12 @@ impl CFDate {
#[inline]
pub fn abs_time(&self) -> CFAbsoluteTime {
- unsafe {
- CFDateGetAbsoluteTime(self.0)
- }
+ unsafe { CFDateGetAbsoluteTime(self.0) }
}
#[cfg(feature = "with-chrono")]
pub fn naive_utc(&self) -> NaiveDateTime {
- let ts = unsafe {
- self.abs_time() + kCFAbsoluteTimeIntervalSince1970
- };
+ let ts = unsafe { self.abs_time() + kCFAbsoluteTimeIntervalSince1970 };
let (secs, nanos) = if ts.is_sign_positive() {
(ts.trunc() as i64, ts.fract())
} else {
@@ -65,9 +60,7 @@ impl CFDate {
pub fn from_naive_utc(time: NaiveDateTime) -> CFDate {
let secs = time.timestamp();
let nanos = time.timestamp_subsec_nanos();
- let ts = unsafe {
- secs as f64 + (nanos as f64 / 1e9) - kCFAbsoluteTimeIntervalSince1970
- };
+ let ts = unsafe { secs as f64 + (nanos as f64 / 1e9) - kCFAbsoluteTimeIntervalSince1970 };
CFDate::new(ts)
}
}
@@ -86,7 +79,7 @@ mod test {
let same_sign = a.is_sign_positive() == b.is_sign_positive();
let equal = ((a - b).abs() / f64::min(a.abs() + b.abs(), f64::MAX)) < f64::EPSILON;
- (same_sign && equal)
+ same_sign && equal
}
#[test]
@@ -119,9 +112,7 @@ mod test {
fn date_chrono_conversion_negative() {
use super::kCFAbsoluteTimeIntervalSince1970;
- let ts = unsafe {
- kCFAbsoluteTimeIntervalSince1970 - 420.0
- };
+ let ts = unsafe { kCFAbsoluteTimeIntervalSince1970 - 420.0 };
let date = CFDate::new(ts);
let datetime: NaiveDateTime = date.naive_utc();
let converted = CFDate::from_naive_utc(datetime);
diff --git a/vendor/core-foundation/src/dictionary.rs b/vendor/core-foundation/src/dictionary.rs
index efcbba117..aad37f3c8 100644
--- a/vendor/core-foundation/src/dictionary.rs
+++ b/vendor/core-foundation/src/dictionary.rs
@@ -11,18 +11,22 @@
pub use core_foundation_sys::dictionary::*;
-use core_foundation_sys::base::{CFTypeRef, CFRelease, kCFAllocatorDefault};
+use core_foundation_sys::base::{kCFAllocatorDefault, CFRelease, CFTypeRef};
+use std::marker::PhantomData;
use std::mem;
use std::os::raw::c_void;
use std::ptr;
-use std::marker::PhantomData;
-use base::{ItemRef, FromVoid, ToVoid};
-use base::{CFIndexConvertible, TCFType};
-use ConcreteCFType;
+use crate::base::{CFIndexConvertible, TCFType};
+use crate::base::{FromVoid, ItemRef, ToVoid};
+use crate::ConcreteCFType;
// consume the type parameters with PhantomDatas
-pub struct CFDictionary<K = *const c_void, V = *const c_void>(CFDictionaryRef, PhantomData<K>, PhantomData<V>);
+pub struct CFDictionary<K = *const c_void, V = *const c_void>(
+ CFDictionaryRef,
+ PhantomData<K>,
+ PhantomData<V>,
+);
impl<K, V> Drop for CFDictionary<K, V> {
fn drop(&mut self) {
@@ -36,19 +40,25 @@ impl_CFTypeDescription!(CFDictionary<K, V>);
unsafe impl ConcreteCFType for CFDictionary<*const c_void, *const c_void> {}
impl<K, V> CFDictionary<K, V> {
- pub fn from_CFType_pairs(pairs: &[(K, V)]) -> CFDictionary<K, V> where K: TCFType, V: TCFType {
+ pub fn from_CFType_pairs(pairs: &[(K, V)]) -> CFDictionary<K, V>
+ where
+ K: TCFType,
+ V: TCFType,
+ {
let (keys, values): (Vec<CFTypeRef>, Vec<CFTypeRef>) = pairs
.iter()
- .map(|&(ref key, ref value)| (key.as_CFTypeRef(), value.as_CFTypeRef()))
+ .map(|(key, value)| (key.as_CFTypeRef(), value.as_CFTypeRef()))
.unzip();
unsafe {
- let dictionary_ref = CFDictionaryCreate(kCFAllocatorDefault,
- keys.as_ptr(),
- values.as_ptr(),
- keys.len().to_CFIndex(),
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
+ let dictionary_ref = CFDictionaryCreate(
+ kCFAllocatorDefault,
+ keys.as_ptr(),
+ values.as_ptr(),
+ keys.len().to_CFIndex(),
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks,
+ );
TCFType::wrap_under_create_rule(dictionary_ref)
}
}
@@ -76,9 +86,7 @@ impl<K, V> CFDictionary<K, V> {
#[inline]
pub fn len(&self) -> usize {
- unsafe {
- CFDictionaryGetCount(self.0) as usize
- }
+ unsafe { CFDictionaryGetCount(self.0) as usize }
}
#[inline]
@@ -87,12 +95,19 @@ impl<K, V> CFDictionary<K, V> {
}
#[inline]
- pub fn contains_key(&self, key: &K) -> bool where K: ToVoid<K> {
+ pub fn contains_key(&self, key: &K) -> bool
+ where
+ K: ToVoid<K>,
+ {
unsafe { CFDictionaryContainsKey(self.0, key.to_void()) != 0 }
}
#[inline]
- pub fn find<'a, T: ToVoid<K>>(&'a self, key: T) -> Option<ItemRef<'a, V>> where V: FromVoid, K: ToVoid<K> {
+ pub fn find<T: ToVoid<K>>(&self, key: T) -> Option<ItemRef<'_, V>>
+ where
+ V: FromVoid,
+ K: ToVoid<K>,
+ {
unsafe {
let mut value: *const c_void = ptr::null();
if CFDictionaryGetValueIfPresent(self.0, key.to_void(), &mut value) != 0 {
@@ -108,9 +123,14 @@ impl<K, V> CFDictionary<K, V> {
/// Panics if the key is not present in the dictionary. Use `find` to get an `Option` instead
/// of panicking.
#[inline]
- pub fn get<'a, T: ToVoid<K>>(&'a self, key: T) -> ItemRef<'a, V> where V: FromVoid, K: ToVoid<K> {
+ pub fn get<T: ToVoid<K>>(&self, key: T) -> ItemRef<'_, V>
+ where
+ V: FromVoid,
+ K: ToVoid<K>,
+ {
let ptr = key.to_void();
- self.find(key).unwrap_or_else(|| panic!("No entry found for key {:p}", ptr))
+ self.find(key)
+ .unwrap_or_else(|| panic!("No entry found for key {:p}", ptr))
}
pub fn get_keys_and_values(&self) -> (Vec<*const c_void>, Vec<*const c_void>) {
@@ -129,7 +149,11 @@ impl<K, V> CFDictionary<K, V> {
}
// consume the type parameters with PhantomDatas
-pub struct CFMutableDictionary<K = *const c_void, V = *const c_void>(CFMutableDictionaryRef, PhantomData<K>, PhantomData<V>);
+pub struct CFMutableDictionary<K = *const c_void, V = *const c_void>(
+ CFMutableDictionaryRef,
+ PhantomData<K>,
+ PhantomData<V>,
+);
impl<K, V> Drop for CFMutableDictionary<K, V> {
fn drop(&mut self) {
@@ -147,24 +171,31 @@ impl<K, V> CFMutableDictionary<K, V> {
pub fn with_capacity(capacity: isize) -> Self {
unsafe {
- let dictionary_ref = CFDictionaryCreateMutable(kCFAllocatorDefault,
- capacity as _,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
+ let dictionary_ref = CFDictionaryCreateMutable(
+ kCFAllocatorDefault,
+ capacity as _,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks,
+ );
TCFType::wrap_under_create_rule(dictionary_ref)
}
}
pub fn copy_with_capacity(&self, capacity: isize) -> Self {
unsafe {
- let dictionary_ref = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, capacity as _, self.0);
+ let dictionary_ref =
+ CFDictionaryCreateMutableCopy(kCFAllocatorDefault, capacity as _, self.0);
TCFType::wrap_under_get_rule(dictionary_ref)
}
}
- pub fn from_CFType_pairs(pairs: &[(K, V)]) -> CFMutableDictionary<K, V> where K: ToVoid<K>, V: ToVoid<V> {
+ pub fn from_CFType_pairs(pairs: &[(K, V)]) -> CFMutableDictionary<K, V>
+ where
+ K: ToVoid<K>,
+ V: ToVoid<V>,
+ {
let mut result = Self::with_capacity(pairs.len() as _);
- for &(ref key, ref value) in pairs {
+ for (key, value) in pairs {
result.add(key, value);
}
result
@@ -194,9 +225,7 @@ impl<K, V> CFMutableDictionary<K, V> {
#[inline]
pub fn len(&self) -> usize {
- unsafe {
- CFDictionaryGetCount(self.0) as usize
- }
+ unsafe { CFDictionaryGetCount(self.0) as usize }
}
#[inline]
@@ -206,13 +235,15 @@ impl<K, V> CFMutableDictionary<K, V> {
#[inline]
pub fn contains_key(&self, key: *const c_void) -> bool {
- unsafe {
- CFDictionaryContainsKey(self.0, key) != 0
- }
+ unsafe { CFDictionaryContainsKey(self.0, key) != 0 }
}
#[inline]
- pub fn find<'a>(&'a self, key: &K) -> Option<ItemRef<'a, V>> where V: FromVoid, K: ToVoid<K> {
+ pub fn find<'a>(&'a self, key: &K) -> Option<ItemRef<'a, V>>
+ where
+ V: FromVoid,
+ K: ToVoid<K>,
+ {
unsafe {
let mut value: *const c_void = ptr::null();
if CFDictionaryGetValueIfPresent(self.0, key.to_void(), &mut value) != 0 {
@@ -228,9 +259,14 @@ impl<K, V> CFMutableDictionary<K, V> {
/// Panics if the key is not present in the dictionary. Use `find` to get an `Option` instead
/// of panicking.
#[inline]
- pub fn get<'a>(&'a self, key: &K) -> ItemRef<'a, V> where V: FromVoid, K: ToVoid<K> {
+ pub fn get<'a>(&'a self, key: &K) -> ItemRef<'a, V>
+ where
+ V: FromVoid,
+ K: ToVoid<K>,
+ {
let ptr = key.to_void();
- self.find(&key).unwrap_or_else(|| panic!("No entry found for key {:p}", ptr))
+ self.find(key)
+ .unwrap_or_else(|| panic!("No entry found for key {:p}", ptr))
}
pub fn get_keys_and_values(&self) -> (Vec<*const c_void>, Vec<*const c_void>) {
@@ -251,25 +287,40 @@ impl<K, V> CFMutableDictionary<K, V> {
/// Adds the key-value pair to the dictionary if no such key already exist.
#[inline]
- pub fn add(&mut self, key: &K, value: &V) where K: ToVoid<K>, V: ToVoid<V> {
+ pub fn add(&mut self, key: &K, value: &V)
+ where
+ K: ToVoid<K>,
+ V: ToVoid<V>,
+ {
unsafe { CFDictionaryAddValue(self.0, key.to_void(), value.to_void()) }
}
/// Sets the value of the key in the dictionary.
#[inline]
- pub fn set(&mut self, key: K, value: V) where K: ToVoid<K>, V: ToVoid<V> {
+ pub fn set(&mut self, key: K, value: V)
+ where
+ K: ToVoid<K>,
+ V: ToVoid<V>,
+ {
unsafe { CFDictionarySetValue(self.0, key.to_void(), value.to_void()) }
}
/// Replaces the value of the key in the dictionary.
#[inline]
- pub fn replace(&mut self, key: K, value: V) where K: ToVoid<K>, V: ToVoid<V> {
+ pub fn replace(&mut self, key: K, value: V)
+ where
+ K: ToVoid<K>,
+ V: ToVoid<V>,
+ {
unsafe { CFDictionaryReplaceValue(self.0, key.to_void(), value.to_void()) }
}
/// Removes the value of the key from the dictionary.
#[inline]
- pub fn remove(&mut self, key: K) where K: ToVoid<K> {
+ pub fn remove(&mut self, key: K)
+ where
+ K: ToVoid<K>,
+ {
unsafe { CFDictionaryRemoveValue(self.0, key.to_void()) }
}
@@ -296,15 +347,13 @@ impl<'a, K, V> From<&'a CFDictionary<K, V>> for CFMutableDictionary<K, V> {
}
}
-
#[cfg(test)]
pub mod test {
use super::*;
- use base::{CFType, TCFType};
- use boolean::CFBoolean;
- use number::CFNumber;
- use string::CFString;
-
+ use crate::base::{CFType, TCFType};
+ use crate::boolean::CFBoolean;
+ use crate::number::CFNumber;
+ use crate::string::CFString;
#[test]
fn dictionary() {
@@ -322,8 +371,14 @@ pub mod test {
]);
let (v1, v2) = d.get_keys_and_values();
- assert_eq!(v1, &[bar.as_CFTypeRef(), baz.as_CFTypeRef(), foo.as_CFTypeRef()]);
- assert_eq!(v2, &[boo.as_CFTypeRef(), tru.as_CFTypeRef(), n42.as_CFTypeRef()]);
+ assert_eq!(
+ v1,
+ &[bar.as_CFTypeRef(), baz.as_CFTypeRef(), foo.as_CFTypeRef()]
+ );
+ assert_eq!(
+ v2,
+ &[boo.as_CFTypeRef(), tru.as_CFTypeRef(), n42.as_CFTypeRef()]
+ );
}
#[test]
@@ -342,8 +397,14 @@ pub mod test {
assert_eq!(d.len(), 3);
let (v1, v2) = d.get_keys_and_values();
- assert_eq!(v1, &[bar.as_CFTypeRef(), baz.as_CFTypeRef(), foo.as_CFTypeRef()]);
- assert_eq!(v2, &[boo.as_CFTypeRef(), tru.as_CFTypeRef(), n42.as_CFTypeRef()]);
+ assert_eq!(
+ v1,
+ &[bar.as_CFTypeRef(), baz.as_CFTypeRef(), foo.as_CFTypeRef()]
+ );
+ assert_eq!(
+ v2,
+ &[boo.as_CFTypeRef(), tru.as_CFTypeRef(), n42.as_CFTypeRef()]
+ );
d.remove(baz);
assert_eq!(d.len(), 2);
@@ -358,12 +419,10 @@ pub mod test {
#[test]
fn dict_find_and_contains_key() {
- let dict = CFDictionary::from_CFType_pairs(&[
- (
- CFString::from_static_string("hello"),
- CFBoolean::true_value(),
- ),
- ]);
+ let dict = CFDictionary::from_CFType_pairs(&[(
+ CFString::from_static_string("hello"),
+ CFBoolean::true_value(),
+ )]);
let key = CFString::from_static_string("hello");
let invalid_key = CFString::from_static_string("foobar");
@@ -377,17 +436,24 @@ pub mod test {
#[test]
fn convert_immutable_to_mutable_dict() {
- let dict: CFDictionary<CFString, CFBoolean> = CFDictionary::from_CFType_pairs(&[
- (CFString::from_static_string("Foo"), CFBoolean::true_value()),
- ]);
+ let dict: CFDictionary<CFString, CFBoolean> = CFDictionary::from_CFType_pairs(&[(
+ CFString::from_static_string("Foo"),
+ CFBoolean::true_value(),
+ )]);
let mut mut_dict = CFMutableDictionary::from(&dict);
assert_eq!(dict.retain_count(), 1);
assert_eq!(mut_dict.retain_count(), 1);
assert_eq!(mut_dict.len(), 1);
- assert_eq!(*mut_dict.get(&CFString::from_static_string("Foo")), CFBoolean::true_value());
-
- mut_dict.add(&CFString::from_static_string("Bar"), &CFBoolean::false_value());
+ assert_eq!(
+ *mut_dict.get(&CFString::from_static_string("Foo")),
+ CFBoolean::true_value()
+ );
+
+ mut_dict.add(
+ &CFString::from_static_string("Bar"),
+ &CFBoolean::false_value(),
+ );
assert_eq!(dict.len(), 1);
assert_eq!(mut_dict.len(), 2);
}
@@ -395,13 +461,19 @@ pub mod test {
#[test]
fn mutable_dictionary_as_immutable() {
let mut mut_dict: CFMutableDictionary<CFString, CFBoolean> = CFMutableDictionary::new();
- mut_dict.add(&CFString::from_static_string("Bar"), &CFBoolean::false_value());
+ mut_dict.add(
+ &CFString::from_static_string("Bar"),
+ &CFBoolean::false_value(),
+ );
assert_eq!(mut_dict.retain_count(), 1);
let dict = mut_dict.to_immutable();
assert_eq!(mut_dict.retain_count(), 2);
assert_eq!(dict.retain_count(), 2);
- assert_eq!(*dict.get(&CFString::from_static_string("Bar")), CFBoolean::false_value());
+ assert_eq!(
+ *dict.get(&CFString::from_static_string("Bar")),
+ CFBoolean::false_value()
+ );
mem::drop(dict);
assert_eq!(mut_dict.retain_count(), 1);
diff --git a/vendor/core-foundation/src/error.rs b/vendor/core-foundation/src/error.rs
index f100171bc..e5a224259 100644
--- a/vendor/core-foundation/src/error.rs
+++ b/vendor/core-foundation/src/error.rs
@@ -14,11 +14,10 @@ pub use core_foundation_sys::error::*;
use std::error::Error;
use std::fmt;
-use base::{CFIndex, TCFType};
-use string::CFString;
+use crate::base::{CFIndex, TCFType};
+use crate::string::CFString;
-
-declare_TCFType!{
+declare_TCFType! {
/// An error value.
CFError, CFErrorRef
}
@@ -27,10 +26,10 @@ impl_TCFType!(CFError, CFErrorRef, CFErrorGetTypeID);
impl fmt::Debug for CFError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("CFError")
- .field("domain", &self.domain())
- .field("code", &self.code())
- .field("description", &self.description())
- .finish()
+ .field("domain", &self.domain())
+ .field("code", &self.code())
+ .field("description", &self.description())
+ .finish()
}
}
diff --git a/vendor/core-foundation/src/filedescriptor.rs b/vendor/core-foundation/src/filedescriptor.rs
index e153c70b2..876d1cec0 100644
--- a/vendor/core-foundation/src/filedescriptor.rs
+++ b/vendor/core-foundation/src/filedescriptor.rs
@@ -9,33 +9,41 @@
pub use core_foundation_sys::filedescriptor::*;
-use core_foundation_sys::base::{Boolean, CFIndex};
use core_foundation_sys::base::{kCFAllocatorDefault, CFOptionFlags};
+use core_foundation_sys::base::{Boolean, CFIndex};
-use base::TCFType;
-use runloop::CFRunLoopSource;
+use crate::base::TCFType;
+use crate::runloop::CFRunLoopSource;
use std::mem::MaybeUninit;
use std::os::unix::io::{AsRawFd, RawFd};
use std::ptr;
-declare_TCFType!{
+declare_TCFType! {
CFFileDescriptor, CFFileDescriptorRef
}
-impl_TCFType!(CFFileDescriptor, CFFileDescriptorRef, CFFileDescriptorGetTypeID);
+impl_TCFType!(
+ CFFileDescriptor,
+ CFFileDescriptorRef,
+ CFFileDescriptorGetTypeID
+);
impl CFFileDescriptor {
- pub fn new(fd: RawFd,
- closeOnInvalidate: bool,
- callout: CFFileDescriptorCallBack,
- context: Option<&CFFileDescriptorContext>) -> Option<CFFileDescriptor> {
+ pub fn new(
+ fd: RawFd,
+ closeOnInvalidate: bool,
+ callout: CFFileDescriptorCallBack,
+ context: Option<&CFFileDescriptorContext>,
+ ) -> Option<CFFileDescriptor> {
let context = context.map_or(ptr::null(), |c| c as *const _);
unsafe {
- let fd_ref = CFFileDescriptorCreate(kCFAllocatorDefault,
- fd,
- closeOnInvalidate as Boolean,
- callout,
- context);
+ let fd_ref = CFFileDescriptorCreate(
+ kCFAllocatorDefault,
+ fd,
+ closeOnInvalidate as Boolean,
+ callout,
+ context,
+ );
if fd_ref.is_null() {
None
} else {
@@ -53,36 +61,25 @@ impl CFFileDescriptor {
}
pub fn enable_callbacks(&self, callback_types: CFOptionFlags) {
- unsafe {
- CFFileDescriptorEnableCallBacks(self.0, callback_types)
- }
+ unsafe { CFFileDescriptorEnableCallBacks(self.0, callback_types) }
}
pub fn disable_callbacks(&self, callback_types: CFOptionFlags) {
- unsafe {
- CFFileDescriptorDisableCallBacks(self.0, callback_types)
- }
+ unsafe { CFFileDescriptorDisableCallBacks(self.0, callback_types) }
}
pub fn valid(&self) -> bool {
- unsafe {
- CFFileDescriptorIsValid(self.0) != 0
- }
+ unsafe { CFFileDescriptorIsValid(self.0) != 0 }
}
pub fn invalidate(&self) {
- unsafe {
- CFFileDescriptorInvalidate(self.0)
- }
+ unsafe { CFFileDescriptorInvalidate(self.0) }
}
pub fn to_run_loop_source(&self, order: CFIndex) -> Option<CFRunLoopSource> {
unsafe {
- let source_ref = CFFileDescriptorCreateRunLoopSource(
- kCFAllocatorDefault,
- self.0,
- order
- );
+ let source_ref =
+ CFFileDescriptorCreateRunLoopSource(kCFAllocatorDefault, self.0, order);
if source_ref.is_null() {
None
} else {
@@ -94,24 +91,21 @@ impl CFFileDescriptor {
impl AsRawFd for CFFileDescriptor {
fn as_raw_fd(&self) -> RawFd {
- unsafe {
- CFFileDescriptorGetNativeDescriptor(self.0)
- }
+ unsafe { CFFileDescriptorGetNativeDescriptor(self.0) }
}
}
-
#[cfg(test)]
mod test {
extern crate libc;
use super::*;
+ use crate::runloop::CFRunLoop;
+ use core_foundation_sys::base::CFOptionFlags;
+ use core_foundation_sys::runloop::kCFRunLoopDefaultMode;
+ use libc::O_RDWR;
use std::ffi::CString;
use std::os::raw::c_void;
- use core_foundation_sys::base::{CFOptionFlags};
- use core_foundation_sys::runloop::{kCFRunLoopDefaultMode};
- use libc::O_RDWR;
- use runloop::{CFRunLoop};
#[test]
fn test_unconsumed() {
@@ -129,14 +123,16 @@ mod test {
assert_eq!(unsafe { libc::close(raw_fd) }, 0);
}
- extern "C" fn never_callback(_f: CFFileDescriptorRef,
- _callback_types: CFOptionFlags,
- _info_ptr: *mut c_void) {
+ extern "C" fn never_callback(
+ _f: CFFileDescriptorRef,
+ _callback_types: CFOptionFlags,
+ _info_ptr: *mut c_void,
+ ) {
unreachable!();
}
struct TestInfo {
- value: CFOptionFlags
+ value: CFOptionFlags,
}
#[test]
@@ -147,7 +143,7 @@ mod test {
info: &mut info as *mut _ as *mut c_void,
retain: None,
release: None,
- copyDescription: None
+ copyDescription: None,
};
let path = CString::new("/dev/null").unwrap();
@@ -182,7 +178,11 @@ mod test {
assert!(!cf_fd.valid());
}
- extern "C" fn callback(_f: CFFileDescriptorRef, callback_types: CFOptionFlags, info_ptr: *mut c_void) {
+ extern "C" fn callback(
+ _f: CFFileDescriptorRef,
+ callback_types: CFOptionFlags,
+ info_ptr: *mut c_void,
+ ) {
assert!(!info_ptr.is_null());
let info: *mut TestInfo = info_ptr as *mut TestInfo;
diff --git a/vendor/core-foundation/src/lib.rs b/vendor/core-foundation/src/lib.rs
index b93593899..767d45aad 100644
--- a/vendor/core-foundation/src/lib.rs
+++ b/vendor/core-foundation/src/lib.rs
@@ -21,7 +21,7 @@ extern crate libc;
#[cfg(feature = "with-chrono")]
extern crate chrono;
-use base::TCFType;
+use crate::base::TCFType;
pub unsafe trait ConcreteCFType: TCFType {}
@@ -165,7 +165,6 @@ macro_rules! impl_TCFType {
(@Phantom $x:ident) => { ::std::marker::PhantomData };
}
-
/// Implement `std::fmt::Debug` for the given type.
///
/// This will invoke the implementation of `Debug` for [`CFType`]
@@ -200,7 +199,14 @@ macro_rules! impl_CFComparison {
#[inline]
fn partial_cmp(&self, other: &$ty) -> Option<::std::cmp::Ordering> {
unsafe {
- Some($compare(self.as_concrete_TypeRef(), other.as_concrete_TypeRef(), ::std::ptr::null_mut()).into())
+ Some(
+ $compare(
+ self.as_concrete_TypeRef(),
+ other.as_concrete_TypeRef(),
+ ::std::ptr::null_mut(),
+ )
+ .into(),
+ )
}
}
}
@@ -211,26 +217,26 @@ macro_rules! impl_CFComparison {
self.partial_cmp(other).unwrap()
}
}
- }
+ };
}
pub mod array;
pub mod attributed_string;
pub mod base;
pub mod boolean;
+pub mod bundle;
pub mod characterset;
pub mod data;
pub mod date;
pub mod dictionary;
pub mod error;
pub mod filedescriptor;
+pub mod mach_port;
pub mod number;
-pub mod set;
-pub mod string;
-pub mod url;
-pub mod bundle;
pub mod propertylist;
pub mod runloop;
+pub mod set;
+pub mod string;
pub mod timezone;
+pub mod url;
pub mod uuid;
-pub mod mach_port;
diff --git a/vendor/core-foundation/src/mach_port.rs b/vendor/core-foundation/src/mach_port.rs
index 6112e3aae..f01847fff 100644
--- a/vendor/core-foundation/src/mach_port.rs
+++ b/vendor/core-foundation/src/mach_port.rs
@@ -1,9 +1,8 @@
-use base::TCFType;
+use crate::base::TCFType;
+use crate::runloop::CFRunLoopSource;
use core_foundation_sys::base::kCFAllocatorDefault;
-use runloop::CFRunLoopSource;
pub use core_foundation_sys::mach_port::*;
-
declare_TCFType! {
/// An immutable numeric value.
CFMachPort, CFMachPortRef
@@ -12,12 +11,10 @@ impl_TCFType!(CFMachPort, CFMachPortRef, CFMachPortGetTypeID);
impl_CFTypeDescription!(CFMachPort);
impl CFMachPort {
- pub fn create_runloop_source(
- &self,
- order: CFIndex,
- ) -> Result<CFRunLoopSource, ()> {
+ pub fn create_runloop_source(&self, order: CFIndex) -> Result<CFRunLoopSource, ()> {
unsafe {
- let runloop_source_ref = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, self.0, order);
+ let runloop_source_ref =
+ CFMachPortCreateRunLoopSource(kCFAllocatorDefault, self.0, order);
if runloop_source_ref.is_null() {
Err(())
} else {
diff --git a/vendor/core-foundation/src/number.rs b/vendor/core-foundation/src/number.rs
index a4b2affaa..c3b6fab96 100644
--- a/vendor/core-foundation/src/number.rs
+++ b/vendor/core-foundation/src/number.rs
@@ -13,10 +13,9 @@ use core_foundation_sys::base::kCFAllocatorDefault;
pub use core_foundation_sys::number::*;
use std::os::raw::c_void;
-use base::TCFType;
+use crate::base::TCFType;
-
-declare_TCFType!{
+declare_TCFType! {
/// An immutable numeric value.
CFNumber, CFNumberRef
}
@@ -25,13 +24,20 @@ impl_CFTypeDescription!(CFNumber);
impl_CFComparison!(CFNumber, CFNumberCompare);
impl CFNumber {
-
#[inline]
pub fn to_i32(&self) -> Option<i32> {
unsafe {
let mut value: i32 = 0;
- let ok = CFNumberGetValue(self.0, kCFNumberSInt32Type, &mut value as *mut i32 as *mut c_void);
- if ok { Some(value) } else { None }
+ let ok = CFNumberGetValue(
+ self.0,
+ kCFNumberSInt32Type,
+ &mut value as *mut i32 as *mut c_void,
+ );
+ if ok {
+ Some(value)
+ } else {
+ None
+ }
}
}
@@ -39,8 +45,16 @@ impl CFNumber {
pub fn to_i64(&self) -> Option<i64> {
unsafe {
let mut value: i64 = 0;
- let ok = CFNumberGetValue(self.0, kCFNumberSInt64Type, &mut value as *mut i64 as *mut c_void);
- if ok { Some(value) } else { None }
+ let ok = CFNumberGetValue(
+ self.0,
+ kCFNumberSInt64Type,
+ &mut value as *mut i64 as *mut c_void,
+ );
+ if ok {
+ Some(value)
+ } else {
+ None
+ }
}
}
@@ -48,8 +62,16 @@ impl CFNumber {
pub fn to_f32(&self) -> Option<f32> {
unsafe {
let mut value: f32 = 0.0;
- let ok = CFNumberGetValue(self.0, kCFNumberFloat32Type, &mut value as *mut f32 as *mut c_void);
- if ok { Some(value) } else { None }
+ let ok = CFNumberGetValue(
+ self.0,
+ kCFNumberFloat32Type,
+ &mut value as *mut f32 as *mut c_void,
+ );
+ if ok {
+ Some(value)
+ } else {
+ None
+ }
}
}
@@ -57,8 +79,16 @@ impl CFNumber {
pub fn to_f64(&self) -> Option<f64> {
unsafe {
let mut value: f64 = 0.0;
- let ok = CFNumberGetValue(self.0, kCFNumberFloat64Type, &mut value as *mut f64 as *mut c_void);
- if ok { Some(value) } else { None }
+ let ok = CFNumberGetValue(
+ self.0,
+ kCFNumberFloat64Type,
+ &mut value as *mut f64 as *mut c_void,
+ );
+ if ok {
+ Some(value)
+ } else {
+ None
+ }
}
}
}
diff --git a/vendor/core-foundation/src/propertylist.rs b/vendor/core-foundation/src/propertylist.rs
index e8fceac58..de5d1d87b 100644
--- a/vendor/core-foundation/src/propertylist.rs
+++ b/vendor/core-foundation/src/propertylist.rs
@@ -9,30 +9,34 @@
//! Core Foundation property lists
-use std::ptr;
use std::mem;
use std::os::raw::c_void;
+use std::ptr;
-use error::CFError;
-use data::CFData;
-use base::{CFType, TCFType, TCFTypeRef};
+use crate::base::{CFType, TCFType, TCFTypeRef};
+use crate::data::CFData;
+use crate::error::CFError;
-pub use core_foundation_sys::propertylist::*;
+use core_foundation_sys::base::{
+ kCFAllocatorDefault, CFGetRetainCount, CFGetTypeID, CFIndex, CFRetain, CFShow, CFTypeID,
+};
use core_foundation_sys::error::CFErrorRef;
-use core_foundation_sys::base::{CFGetRetainCount, CFGetTypeID, CFIndex, CFRetain,
- CFShow, CFTypeID, kCFAllocatorDefault};
+pub use core_foundation_sys::propertylist::*;
-pub fn create_with_data(data: CFData,
- options: CFPropertyListMutabilityOptions)
- -> Result<(*const c_void, CFPropertyListFormat), CFError> {
+pub fn create_with_data(
+ data: CFData,
+ options: CFPropertyListMutabilityOptions,
+) -> Result<(*const c_void, CFPropertyListFormat), CFError> {
unsafe {
let mut error: CFErrorRef = ptr::null_mut();
let mut format: CFPropertyListFormat = 0;
- let property_list = CFPropertyListCreateWithData(kCFAllocatorDefault,
- data.as_concrete_TypeRef(),
- options,
- &mut format,
- &mut error);
+ let property_list = CFPropertyListCreateWithData(
+ kCFAllocatorDefault,
+ data.as_concrete_TypeRef(),
+ options,
+ &mut format,
+ &mut error,
+ );
if property_list.is_null() {
Err(TCFType::wrap_under_create_rule(error))
} else {
@@ -41,14 +45,14 @@ pub fn create_with_data(data: CFData,
}
}
-pub fn create_data(property_list: *const c_void, format: CFPropertyListFormat) -> Result<CFData, CFError> {
+pub fn create_data(
+ property_list: *const c_void,
+ format: CFPropertyListFormat,
+) -> Result<CFData, CFError> {
unsafe {
let mut error: CFErrorRef = ptr::null_mut();
- let data_ref = CFPropertyListCreateData(kCFAllocatorDefault,
- property_list,
- format,
- 0,
- &mut error);
+ let data_ref =
+ CFPropertyListCreateData(kCFAllocatorDefault, property_list, format, 0, &mut error);
if data_ref.is_null() {
Err(TCFType::wrap_under_create_rule(error))
} else {
@@ -57,7 +61,6 @@ pub fn create_data(property_list: *const c_void, format: CFPropertyListFormat) -
}
}
-
/// Trait for all subclasses of [`CFPropertyList`].
///
/// [`CFPropertyList`]: struct.CFPropertyList.html
@@ -84,16 +87,15 @@ pub trait CFPropertyListSubClass: TCFType {
}
}
-impl CFPropertyListSubClass for ::data::CFData {}
-impl CFPropertyListSubClass for ::string::CFString {}
-impl CFPropertyListSubClass for ::array::CFArray {}
-impl CFPropertyListSubClass for ::dictionary::CFDictionary {}
-impl CFPropertyListSubClass for ::date::CFDate {}
-impl CFPropertyListSubClass for ::boolean::CFBoolean {}
-impl CFPropertyListSubClass for ::number::CFNumber {}
-
+impl CFPropertyListSubClass for crate::data::CFData {}
+impl CFPropertyListSubClass for crate::string::CFString {}
+impl CFPropertyListSubClass for crate::array::CFArray {}
+impl CFPropertyListSubClass for crate::dictionary::CFDictionary {}
+impl CFPropertyListSubClass for crate::date::CFDate {}
+impl CFPropertyListSubClass for crate::boolean::CFBoolean {}
+impl CFPropertyListSubClass for crate::number::CFNumber {}
-declare_TCFType!{
+declare_TCFType! {
/// A CFPropertyList struct. This is superclass to [`CFData`], [`CFString`], [`CFArray`],
/// [`CFDictionary`], [`CFDate`], [`CFBoolean`], and [`CFNumber`].
///
@@ -161,8 +163,8 @@ impl CFPropertyList {
unsafe { CFGetRetainCount(self.as_CFTypeRef()) }
}
- /// Returns the type ID of this object. Will be one of CFData, CFString, CFArray, CFDictionary,
- /// CFDate, CFBoolean, or CFNumber.
+ /// Returns the type ID of this object. Will be one of `CFData`, `CFString`, `CFArray`,
+ /// `CFDictionary`, `CFDate`, `CFBoolean`, or `CFNumber`.
#[inline]
pub fn type_of(&self) -> CFTypeID {
unsafe { CFGetTypeID(self.as_CFTypeRef()) }
@@ -173,7 +175,7 @@ impl CFPropertyList {
unsafe { CFShow(self.as_CFTypeRef()) }
}
- /// Returns true if this value is an instance of another type.
+ /// Returns `true` if this value is an instance of another type.
#[inline]
pub fn instance_of<OtherCFType: TCFType>(&self) -> bool {
self.type_of() == OtherCFType::type_id()
@@ -244,33 +246,33 @@ impl CFPropertyList {
}
}
-
-
#[cfg(test)]
pub mod test {
use super::*;
- use string::CFString;
- use boolean::CFBoolean;
+ use crate::boolean::CFBoolean;
+ use crate::string::CFString;
#[test]
fn test_property_list_serialization() {
- use base::{TCFType, CFEqual};
- use boolean::CFBoolean;
- use number::CFNumber;
- use dictionary::CFDictionary;
- use string::CFString;
use super::*;
+ use crate::base::{CFEqual, TCFType};
+ use crate::boolean::CFBoolean;
+ use crate::dictionary::CFDictionary;
+ use crate::number::CFNumber;
+ use crate::string::CFString;
let bar = CFString::from_static_string("Bar");
let baz = CFString::from_static_string("Baz");
let boo = CFString::from_static_string("Boo");
let foo = CFString::from_static_string("Foo");
let tru = CFBoolean::true_value();
- let n42 = CFNumber::from(1i64<<33);
+ let n42 = CFNumber::from(1i64 << 33);
- let dict1 = CFDictionary::from_CFType_pairs(&[(bar.as_CFType(), boo.as_CFType()),
- (baz.as_CFType(), tru.as_CFType()),
- (foo.as_CFType(), n42.as_CFType())]);
+ let dict1 = CFDictionary::from_CFType_pairs(&[
+ (bar.as_CFType(), boo.as_CFType()),
+ (baz.as_CFType(), tru.as_CFType()),
+ (foo.as_CFType(), n42.as_CFType()),
+ ]);
let data = create_data(dict1.as_CFTypeRef(), kCFPropertyListXMLFormat_v1_0).unwrap();
let (dict2, _) = create_with_data(data, kCFPropertyListImmutable).unwrap();
@@ -281,7 +283,7 @@ pub mod test {
#[test]
fn to_propertylist_retain_count() {
- let string = CFString::from_static_string("Bar");
+ let string = CFString::from_static_string("alongerstring");
assert_eq!(string.retain_count(), 1);
let propertylist = string.to_CFPropertyList();
@@ -295,7 +297,10 @@ pub mod test {
#[test]
fn downcast_string() {
let propertylist = CFString::from_static_string("Bar").to_CFPropertyList();
- assert_eq!(propertylist.downcast::<CFString>().unwrap().to_string(), "Bar");
+ assert_eq!(
+ propertylist.downcast::<CFString>().unwrap().to_string(),
+ "Bar"
+ );
assert!(propertylist.downcast::<CFBoolean>().is_none());
}
@@ -308,7 +313,7 @@ pub mod test {
#[test]
fn downcast_into_fail() {
- let string = CFString::from_static_string("Bar");
+ let string = CFString::from_static_string("alongerstring");
let propertylist = string.to_CFPropertyList();
assert_eq!(string.retain_count(), 2);
@@ -318,12 +323,12 @@ pub mod test {
#[test]
fn downcast_into() {
- let string = CFString::from_static_string("Bar");
+ let string = CFString::from_static_string("alongerstring");
let propertylist = string.to_CFPropertyList();
assert_eq!(string.retain_count(), 2);
let string2 = propertylist.downcast_into::<CFString>().unwrap();
- assert_eq!(string2.to_string(), "Bar");
+ assert_eq!(string2.to_string(), "alongerstring");
assert_eq!(string2.retain_count(), 2);
}
}
diff --git a/vendor/core-foundation/src/runloop.rs b/vendor/core-foundation/src/runloop.rs
index be06f4ec7..304c0716d 100644
--- a/vendor/core-foundation/src/runloop.rs
+++ b/vendor/core-foundation/src/runloop.rs
@@ -9,23 +9,26 @@
#![allow(non_upper_case_globals)]
-pub use core_foundation_sys::runloop::*;
use core_foundation_sys::base::CFIndex;
use core_foundation_sys::base::{kCFAllocatorDefault, CFOptionFlags};
+pub use core_foundation_sys::runloop::*;
use core_foundation_sys::string::CFStringRef;
-use base::{TCFType};
-use date::{CFAbsoluteTime, CFTimeInterval};
-use filedescriptor::CFFileDescriptor;
-use string::{CFString};
+use crate::base::TCFType;
+use crate::date::{CFAbsoluteTime, CFTimeInterval};
+use crate::filedescriptor::CFFileDescriptor;
+use crate::string::CFString;
pub type CFRunLoopMode = CFStringRef;
-
declare_TCFType!(CFRunLoop, CFRunLoopRef);
impl_TCFType!(CFRunLoop, CFRunLoopRef, CFRunLoopGetTypeID);
impl_CFTypeDescription!(CFRunLoop);
+// https://github.com/servo/core-foundation-rs/issues/550
+unsafe impl Send for CFRunLoop {}
+unsafe impl Sync for CFRunLoop {}
+
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum CFRunLoopRunResult {
Finished = 1,
@@ -92,9 +95,7 @@ impl CFRunLoop {
}
pub fn contains_timer(&self, timer: &CFRunLoopTimer, mode: CFRunLoopMode) -> bool {
- unsafe {
- CFRunLoopContainsTimer(self.0, timer.0, mode) != 0
- }
+ unsafe { CFRunLoopContainsTimer(self.0, timer.0, mode) != 0 }
}
pub fn add_timer(&self, timer: &CFRunLoopTimer, mode: CFRunLoopMode) {
@@ -110,9 +111,7 @@ impl CFRunLoop {
}
pub fn contains_source(&self, source: &CFRunLoopSource, mode: CFRunLoopMode) -> bool {
- unsafe {
- CFRunLoopContainsSource(self.0, source.0, mode) != 0
- }
+ unsafe { CFRunLoopContainsSource(self.0, source.0, mode) != 0 }
}
pub fn add_source(&self, source: &CFRunLoopSource, mode: CFRunLoopMode) {
@@ -128,9 +127,7 @@ impl CFRunLoop {
}
pub fn contains_observer(&self, observer: &CFRunLoopObserver, mode: CFRunLoopMode) -> bool {
- unsafe {
- CFRunLoopContainsObserver(self.0, observer.0, mode) != 0
- }
+ unsafe { CFRunLoopContainsObserver(self.0, observer.0, mode) != 0 }
}
pub fn add_observer(&self, observer: &CFRunLoopObserver, mode: CFRunLoopMode) {
@@ -144,25 +141,41 @@ impl CFRunLoop {
CFRunLoopRemoveObserver(self.0, observer.0, mode);
}
}
-
}
-
declare_TCFType!(CFRunLoopTimer, CFRunLoopTimerRef);
impl_TCFType!(CFRunLoopTimer, CFRunLoopTimerRef, CFRunLoopTimerGetTypeID);
impl CFRunLoopTimer {
- pub fn new(fireDate: CFAbsoluteTime, interval: CFTimeInterval, flags: CFOptionFlags, order: CFIndex, callout: CFRunLoopTimerCallBack, context: *mut CFRunLoopTimerContext) -> CFRunLoopTimer {
+ pub fn new(
+ fireDate: CFAbsoluteTime,
+ interval: CFTimeInterval,
+ flags: CFOptionFlags,
+ order: CFIndex,
+ callout: CFRunLoopTimerCallBack,
+ context: *mut CFRunLoopTimerContext,
+ ) -> CFRunLoopTimer {
unsafe {
- let timer_ref = CFRunLoopTimerCreate(kCFAllocatorDefault, fireDate, interval, flags, order, callout, context);
+ let timer_ref = CFRunLoopTimerCreate(
+ kCFAllocatorDefault,
+ fireDate,
+ interval,
+ flags,
+ order,
+ callout,
+ context,
+ );
TCFType::wrap_under_create_rule(timer_ref)
}
}
}
-
declare_TCFType!(CFRunLoopSource, CFRunLoopSourceRef);
-impl_TCFType!(CFRunLoopSource, CFRunLoopSourceRef, CFRunLoopSourceGetTypeID);
+impl_TCFType!(
+ CFRunLoopSource,
+ CFRunLoopSourceRef,
+ CFRunLoopSourceGetTypeID
+);
impl CFRunLoopSource {
pub fn from_file_descriptor(fd: &CFFileDescriptor, order: CFIndex) -> Option<CFRunLoopSource> {
@@ -171,15 +184,23 @@ impl CFRunLoopSource {
}
declare_TCFType!(CFRunLoopObserver, CFRunLoopObserverRef);
-impl_TCFType!(CFRunLoopObserver, CFRunLoopObserverRef, CFRunLoopObserverGetTypeID);
+impl_TCFType!(
+ CFRunLoopObserver,
+ CFRunLoopObserverRef,
+ CFRunLoopObserverGetTypeID
+);
#[cfg(test)]
mod test {
use super::*;
- use date::{CFDate, CFAbsoluteTime};
+ use crate::base::Boolean;
+ use crate::date::{CFAbsoluteTime, CFDate};
use std::mem;
use std::os::raw::c_void;
+ use std::ptr::null_mut;
use std::sync::mpsc;
+ use std::thread::spawn;
+ use std::time::Duration;
#[test]
fn wait_200_milliseconds() {
@@ -199,7 +220,8 @@ mod test {
copyDescription: None,
};
- let run_loop_timer = CFRunLoopTimer::new(now + 0.20f64, 0f64, 0, 0, timer_popped, &mut context);
+ let run_loop_timer =
+ CFRunLoopTimer::new(now + 0.20f64, 0f64, 0, 0, timer_popped, &mut context);
unsafe {
run_loop.add_timer(&run_loop_timer, kCFRunLoopDefaultMode);
}
@@ -221,4 +243,62 @@ mod test {
let _ = unsafe { (*info).elapsed_tx.send(elapsed) };
CFRunLoop::get_current().stop();
}
+
+ extern "C" fn observe(_: CFRunLoopObserverRef, _: CFRunLoopActivity, context: *mut c_void) {
+ let tx: &mpsc::Sender<CFRunLoop> = unsafe { &*(context as *const _) };
+ let _ = tx.send(CFRunLoop::get_current());
+ }
+
+ extern "C" fn observe_timer_popped(_: CFRunLoopTimerRef, _: *mut c_void) {
+ panic!("timer popped unexpectedly");
+ }
+
+ #[test]
+ fn observe_runloop() {
+ let (tx, rx) = mpsc::channel();
+ spawn(move || {
+ let mut context = CFRunLoopObserverContext {
+ version: 0,
+ info: &tx as *const _ as *mut c_void,
+ retain: None,
+ release: None,
+ copyDescription: None,
+ };
+
+ let observer = unsafe {
+ CFRunLoopObserver::wrap_under_create_rule(CFRunLoopObserverCreate(
+ kCFAllocatorDefault,
+ kCFRunLoopEntry,
+ false as Boolean,
+ 0,
+ observe,
+ &mut context,
+ ))
+ };
+
+ let runloop = CFRunLoop::get_current();
+ runloop.add_observer(&observer, unsafe { kCFRunLoopDefaultMode });
+
+ let timer = CFRunLoopTimer::new(
+ CFDate::now().abs_time() + 1f64,
+ 0f64,
+ 0,
+ 0,
+ observe_timer_popped,
+ null_mut(),
+ );
+ runloop.add_timer(&timer, unsafe { kCFRunLoopDefaultMode });
+
+ let result = unsafe {
+ CFRunLoop::run_in_mode(kCFRunLoopDefaultMode, Duration::from_secs(10), false)
+ };
+
+ assert_eq!(result, CFRunLoopRunResult::Stopped);
+
+ drop(tx);
+ });
+
+ let runloop: CFRunLoop = rx.recv().unwrap();
+ runloop.stop();
+ }
}
diff --git a/vendor/core-foundation/src/set.rs b/vendor/core-foundation/src/set.rs
index eb1d357a0..641202de8 100644
--- a/vendor/core-foundation/src/set.rs
+++ b/vendor/core-foundation/src/set.rs
@@ -9,13 +9,13 @@
//! An immutable bag of elements.
+use core_foundation_sys::base::{kCFAllocatorDefault, CFRelease, CFTypeRef};
pub use core_foundation_sys::set::*;
-use core_foundation_sys::base::{CFTypeRef, CFRelease, kCFAllocatorDefault};
-use base::{CFIndexConvertible, TCFType};
+use crate::base::{CFIndexConvertible, TCFType};
-use std::os::raw::c_void;
use std::marker::PhantomData;
+use std::os::raw::c_void;
/// An immutable bag of elements.
pub struct CFSet<T = *const c_void>(CFSetRef, PhantomData<T>);
@@ -31,23 +31,31 @@ impl_CFTypeDescription!(CFSet);
impl CFSet {
/// Creates a new set from a list of `CFType` instances.
- pub fn from_slice<T>(elems: &[T]) -> CFSet<T> where T: TCFType {
+ pub fn from_slice<T>(elems: &[T]) -> CFSet<T>
+ where
+ T: TCFType,
+ {
unsafe {
let elems: Vec<CFTypeRef> = elems.iter().map(|elem| elem.as_CFTypeRef()).collect();
- let set_ref = CFSetCreate(kCFAllocatorDefault,
- elems.as_ptr(),
- elems.len().to_CFIndex(),
- &kCFTypeSetCallBacks);
+ let set_ref = CFSetCreate(
+ kCFAllocatorDefault,
+ elems.as_ptr(),
+ elems.len().to_CFIndex(),
+ &kCFTypeSetCallBacks,
+ );
TCFType::wrap_under_create_rule(set_ref)
}
}
}
impl<T> CFSet<T> {
- /// Get the number of elements in the CFSet
+ /// Get the number of elements in the `CFSet`.
pub fn len(&self) -> usize {
- unsafe {
- CFSetGetCount(self.0) as usize
- }
+ unsafe { CFSetGetCount(self.0) as usize }
+ }
+
+ /// Returns `true` if the set contains no elements.
+ pub fn is_empty(&self) -> bool {
+ self.len() == 0
}
}
diff --git a/vendor/core-foundation/src/string.rs b/vendor/core-foundation/src/string.rs
index 3f5994bc5..3358bab55 100644
--- a/vendor/core-foundation/src/string.rs
+++ b/vendor/core-foundation/src/string.rs
@@ -11,18 +11,17 @@
pub use core_foundation_sys::string::*;
-use base::{CFIndexConvertible, TCFType};
+use crate::base::{CFIndexConvertible, TCFType};
-use core_foundation_sys::base::{Boolean, CFIndex, CFRange};
use core_foundation_sys::base::{kCFAllocatorDefault, kCFAllocatorNull};
+use core_foundation_sys::base::{Boolean, CFIndex, CFRange};
use std::borrow::Cow;
+use std::ffi::CStr;
use std::fmt;
-use std::str::{self, FromStr};
use std::ptr;
-use std::ffi::CStr;
-
+use std::str::{self, FromStr};
-declare_TCFType!{
+declare_TCFType! {
/// An immutable string in one of a variety of encodings.
CFString, CFStringRef
}
@@ -31,7 +30,7 @@ impl_TCFType!(CFString, CFStringRef, CFStringGetTypeID);
impl FromStr for CFString {
type Err = ();
- /// See also CFString::new for a variant of this which does not return a Result
+ /// See also [`CFString::new()`] for a variant of this which does not return a `Result`.
#[inline]
fn from_str(string: &str) -> Result<CFString, ()> {
Ok(CFString::new(string))
@@ -58,27 +57,37 @@ impl<'a> From<&'a CFString> for Cow<'a, str> {
// First, ask how big the buffer ought to be.
let mut bytes_required: CFIndex = 0;
- CFStringGetBytes(cf_str.0,
- CFRange { location: 0, length: char_len },
- kCFStringEncodingUTF8,
- 0,
- false as Boolean,
- ptr::null_mut(),
- 0,
- &mut bytes_required);
+ CFStringGetBytes(
+ cf_str.0,
+ CFRange {
+ location: 0,
+ length: char_len,
+ },
+ kCFStringEncodingUTF8,
+ 0,
+ false as Boolean,
+ ptr::null_mut(),
+ 0,
+ &mut bytes_required,
+ );
// Then, allocate the buffer and actually copy.
let mut buffer = vec![b'\x00'; bytes_required as usize];
let mut bytes_used: CFIndex = 0;
- let chars_written = CFStringGetBytes(cf_str.0,
- CFRange { location: 0, length: char_len },
- kCFStringEncodingUTF8,
- 0,
- false as Boolean,
- buffer.as_mut_ptr(),
- buffer.len().to_CFIndex(),
- &mut bytes_used);
+ let chars_written = CFStringGetBytes(
+ cf_str.0,
+ CFRange {
+ location: 0,
+ length: char_len,
+ },
+ kCFStringEncodingUTF8,
+ 0,
+ false as Boolean,
+ buffer.as_mut_ptr(),
+ buffer.len().to_CFIndex(),
+ &mut bytes_used,
+ );
assert_eq!(chars_written, char_len);
// This is dangerous; we over-allocate and null-terminate the string (during
@@ -102,17 +111,18 @@ impl fmt::Debug for CFString {
}
}
-
impl CFString {
/// Creates a new `CFString` instance from a Rust string.
#[inline]
pub fn new(string: &str) -> CFString {
unsafe {
- let string_ref = CFStringCreateWithBytes(kCFAllocatorDefault,
- string.as_ptr(),
- string.len().to_CFIndex(),
- kCFStringEncodingUTF8,
- false as Boolean);
+ let string_ref = CFStringCreateWithBytes(
+ kCFAllocatorDefault,
+ string.as_ptr(),
+ string.len().to_CFIndex(),
+ kCFStringEncodingUTF8,
+ false as Boolean,
+ );
CFString::wrap_under_create_rule(string_ref)
}
}
@@ -122,12 +132,14 @@ impl CFString {
#[inline]
pub fn from_static_string(string: &'static str) -> CFString {
unsafe {
- let string_ref = CFStringCreateWithBytesNoCopy(kCFAllocatorDefault,
- string.as_ptr(),
- string.len().to_CFIndex(),
- kCFStringEncodingUTF8,
- false as Boolean,
- kCFAllocatorNull);
+ let string_ref = CFStringCreateWithBytesNoCopy(
+ kCFAllocatorDefault,
+ string.as_ptr(),
+ string.len().to_CFIndex(),
+ kCFStringEncodingUTF8,
+ false as Boolean,
+ kCFAllocatorNull,
+ );
TCFType::wrap_under_create_rule(string_ref)
}
}
@@ -135,21 +147,21 @@ impl CFString {
/// Returns the number of characters in the string.
#[inline]
pub fn char_len(&self) -> CFIndex {
- unsafe {
- CFStringGetLength(self.0)
- }
+ unsafe { CFStringGetLength(self.0) }
}
}
impl<'a> PartialEq<&'a str> for CFString {
fn eq(&self, other: &&str) -> bool {
unsafe {
- let temp = CFStringCreateWithBytesNoCopy(kCFAllocatorDefault,
- other.as_ptr(),
- other.len().to_CFIndex(),
- kCFStringEncodingUTF8,
- false as Boolean,
- kCFAllocatorNull);
+ let temp = CFStringCreateWithBytesNoCopy(
+ kCFAllocatorDefault,
+ other.as_ptr(),
+ other.len().to_CFIndex(),
+ kCFStringEncodingUTF8,
+ false as Boolean,
+ kCFAllocatorNull,
+ );
self.eq(&CFString::wrap_under_create_rule(temp))
}
}
diff --git a/vendor/core-foundation/src/timezone.rs b/vendor/core-foundation/src/timezone.rs
index a8bb2ed1d..46123dcc2 100644
--- a/vendor/core-foundation/src/timezone.rs
+++ b/vendor/core-foundation/src/timezone.rs
@@ -9,18 +9,17 @@
//! Core Foundation time zone objects.
-pub use core_foundation_sys::timezone::*;
use core_foundation_sys::base::kCFAllocatorDefault;
+pub use core_foundation_sys::timezone::*;
-use base::TCFType;
-use date::{CFDate, CFTimeInterval};
-use string::CFString;
+use crate::base::TCFType;
+use crate::date::{CFDate, CFTimeInterval};
+use crate::string::CFString;
#[cfg(feature = "with-chrono")]
use chrono::{FixedOffset, NaiveDateTime};
-
-declare_TCFType!{
+declare_TCFType! {
/// A time zone.
CFTimeZone, CFTimeZoneRef
}
@@ -54,9 +53,7 @@ impl CFTimeZone {
}
pub fn seconds_from_gmt(&self, date: CFDate) -> CFTimeInterval {
- unsafe {
- CFTimeZoneGetSecondsFromGMT(self.0, date.abs_time())
- }
+ unsafe { CFTimeZoneGetSecondsFromGMT(self.0, date.abs_time()) }
}
#[cfg(feature = "with-chrono")]
@@ -70,12 +67,10 @@ impl CFTimeZone {
CFTimeZone::new(offset.local_minus_utc() as f64)
}
- /// The timezone database ID that identifies the time zone. E.g. "America/Los_Angeles" or
- /// "Europe/Paris".
+ /// The timezone database ID that identifies the time zone. E.g. `"America/Los_Angeles" `or
+ /// `"Europe/Paris"`.
pub fn name(&self) -> CFString {
- unsafe {
- CFString::wrap_under_get_rule(CFTimeZoneGetName(self.0))
- }
+ unsafe { CFString::wrap_under_get_rule(CFTimeZoneGetName(self.0)) }
}
}
@@ -84,7 +79,7 @@ mod test {
use super::CFTimeZone;
#[cfg(feature = "with-chrono")]
- use chrono::{NaiveDateTime, FixedOffset};
+ use chrono::{FixedOffset, NaiveDateTime};
#[test]
fn timezone_comparison() {
diff --git a/vendor/core-foundation/src/url.rs b/vendor/core-foundation/src/url.rs
index 064dd7b5e..b92984438 100644
--- a/vendor/core-foundation/src/url.rs
+++ b/vendor/core-foundation/src/url.rs
@@ -11,21 +11,20 @@
pub use core_foundation_sys::url::*;
-use base::{TCFType, CFIndex};
-use string::{CFString};
+use crate::base::{CFIndex, TCFType};
+use crate::string::CFString;
use core_foundation_sys::base::{kCFAllocatorDefault, Boolean};
use std::fmt;
-use std::ptr;
use std::path::{Path, PathBuf};
+use std::ptr;
use libc::{c_char, strlen, PATH_MAX};
#[cfg(unix)]
-use std::os::unix::ffi::OsStrExt;
-#[cfg(unix)]
use std::ffi::OsStr;
-
+#[cfg(unix)]
+use std::os::unix::ffi::OsStrExt;
declare_TCFType!(CFURL, CFURLRef);
impl_TCFType!(CFURL, CFURLRef, CFURLGetTypeID);
@@ -35,7 +34,7 @@ impl fmt::Debug for CFURL {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
unsafe {
let string: CFString = TCFType::wrap_under_get_rule(CFURLGetString(self.0));
- write!(f, "{}", string.to_string())
+ write!(f, "{}", string)
}
}
}
@@ -58,7 +57,12 @@ impl CFURL {
}
unsafe {
- let url_ref = CFURLCreateFromFileSystemRepresentation(ptr::null_mut(), path_bytes.as_ptr(), path_bytes.len() as CFIndex, isDirectory as u8);
+ let url_ref = CFURLCreateFromFileSystemRepresentation(
+ ptr::null_mut(),
+ path_bytes.as_ptr(),
+ path_bytes.len() as CFIndex,
+ isDirectory as u8,
+ );
if url_ref.is_null() {
return None;
}
@@ -66,9 +70,18 @@ impl CFURL {
}
}
- pub fn from_file_system_path(filePath: CFString, pathStyle: CFURLPathStyle, isDirectory: bool) -> CFURL {
+ pub fn from_file_system_path(
+ filePath: CFString,
+ pathStyle: CFURLPathStyle,
+ isDirectory: bool,
+ ) -> CFURL {
unsafe {
- let url_ref = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, filePath.as_concrete_TypeRef(), pathStyle, isDirectory as u8);
+ let url_ref = CFURLCreateWithFileSystemPath(
+ kCFAllocatorDefault,
+ filePath.as_concrete_TypeRef(),
+ pathStyle,
+ isDirectory as u8,
+ );
TCFType::wrap_under_create_rule(url_ref)
}
}
@@ -78,7 +91,12 @@ impl CFURL {
// implementing this on Windows is more complicated because of the different OsStr representation
unsafe {
let mut buf = [0u8; PATH_MAX as usize];
- let result = CFURLGetFileSystemRepresentation(self.0, true as Boolean, buf.as_mut_ptr(), buf.len() as CFIndex);
+ let result = CFURLGetFileSystemRepresentation(
+ self.0,
+ true as Boolean,
+ buf.as_mut_ptr(),
+ buf.len() as CFIndex,
+ );
if result == false as Boolean {
return None;
}
@@ -89,21 +107,20 @@ impl CFURL {
}
pub fn get_string(&self) -> CFString {
- unsafe {
- TCFType::wrap_under_get_rule(CFURLGetString(self.0))
- }
+ unsafe { TCFType::wrap_under_get_rule(CFURLGetString(self.0)) }
}
pub fn get_file_system_path(&self, pathStyle: CFURLPathStyle) -> CFString {
unsafe {
- TCFType::wrap_under_create_rule(CFURLCopyFileSystemPath(self.as_concrete_TypeRef(), pathStyle))
+ TCFType::wrap_under_create_rule(CFURLCopyFileSystemPath(
+ self.as_concrete_TypeRef(),
+ pathStyle,
+ ))
}
}
pub fn absolute(&self) -> CFURL {
- unsafe {
- TCFType::wrap_under_create_rule(CFURLCopyAbsoluteURL(self.as_concrete_TypeRef()))
- }
+ unsafe { TCFType::wrap_under_create_rule(CFURLCopyAbsoluteURL(self.as_concrete_TypeRef())) }
}
}
@@ -138,18 +155,30 @@ fn absolute_file_url() {
let cfstr_file = CFString::from_static_string(file);
let cfurl_base = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true);
let cfurl_relative: CFURL = unsafe {
- let url_ref = CFURLCreateWithFileSystemPathRelativeToBase(kCFAllocatorDefault,
+ let url_ref = CFURLCreateWithFileSystemPathRelativeToBase(
+ kCFAllocatorDefault,
cfstr_file.as_concrete_TypeRef(),
kCFURLPOSIXPathStyle,
false as u8,
- cfurl_base.as_concrete_TypeRef());
+ cfurl_base.as_concrete_TypeRef(),
+ );
TCFType::wrap_under_create_rule(url_ref)
};
let mut absolute_path = PathBuf::from(path);
absolute_path.push(file);
- assert_eq!(cfurl_relative.get_file_system_path(kCFURLPOSIXPathStyle).to_string(), file);
- assert_eq!(cfurl_relative.absolute().get_file_system_path(kCFURLPOSIXPathStyle).to_string(),
- absolute_path.to_str().unwrap());
+ assert_eq!(
+ cfurl_relative
+ .get_file_system_path(kCFURLPOSIXPathStyle)
+ .to_string(),
+ file
+ );
+ assert_eq!(
+ cfurl_relative
+ .absolute()
+ .get_file_system_path(kCFURLPOSIXPathStyle)
+ .to_string(),
+ absolute_path.to_str().unwrap()
+ );
}
diff --git a/vendor/core-foundation/src/uuid.rs b/vendor/core-foundation/src/uuid.rs
index 6be734dab..834a6dd9d 100644
--- a/vendor/core-foundation/src/uuid.rs
+++ b/vendor/core-foundation/src/uuid.rs
@@ -12,15 +12,14 @@
#[cfg(feature = "with-uuid")]
extern crate uuid;
-pub use core_foundation_sys::uuid::*;
use core_foundation_sys::base::kCFAllocatorDefault;
+pub use core_foundation_sys::uuid::*;
-use base::TCFType;
+use crate::base::TCFType;
#[cfg(feature = "with-uuid")]
use self::uuid::Uuid;
-
declare_TCFType! {
/// A UUID.
CFUUID, CFUUIDRef
@@ -45,28 +44,12 @@ impl Default for CFUUID {
}
#[cfg(feature = "with-uuid")]
-impl Into<Uuid> for CFUUID {
- fn into(self) -> Uuid {
- let b = unsafe {
- CFUUIDGetUUIDBytes(self.0)
- };
+impl From<CFUUID> for Uuid {
+ fn from(val: CFUUID) -> Self {
+ let b = unsafe { CFUUIDGetUUIDBytes(val.0) };
let bytes = [
- b.byte0,
- b.byte1,
- b.byte2,
- b.byte3,
- b.byte4,
- b.byte5,
- b.byte6,
- b.byte7,
- b.byte8,
- b.byte9,
- b.byte10,
- b.byte11,
- b.byte12,
- b.byte13,
- b.byte14,
- b.byte15,
+ b.byte0, b.byte1, b.byte2, b.byte3, b.byte4, b.byte5, b.byte6, b.byte7, b.byte8,
+ b.byte9, b.byte10, b.byte11, b.byte12, b.byte13, b.byte14, b.byte15,
];
Uuid::from_bytes(&bytes).unwrap()
}
@@ -101,7 +84,6 @@ impl From<Uuid> for CFUUID {
}
}
-
#[cfg(test)]
#[cfg(feature = "with-uuid")]
mod test {