diff --git a/cidre/src/cf/dictionary.rs b/cidre/src/cf/dictionary.rs index 1b2396bf..3171b490 100644 --- a/cidre/src/cf/dictionary.rs +++ b/cidre/src/cf/dictionary.rs @@ -379,7 +379,10 @@ extern "C" { } -define_cf_type!(DictionaryMut(Dictionary)); +define_cf_type!( + #[doc(alias = "CFMutableDictionary")] + DictionaryMut(Dictionary) +); impl DictionaryMut { pub fn with_capacity(capacity: usize) -> arc::R { @@ -482,6 +485,19 @@ where } } +impl DictionaryOf { + pub fn value<'a>(&'a self, key: &cf::String) -> Option<&'a cf::Plist> { + let mut result = None; + unsafe { + if CFDictionaryGetValueIfPresent(&self.0, key.as_type_ptr(), &mut result) { + Some(std::mem::transmute(result)) + } else { + None + } + } + } +} + impl std::ops::Deref for DictionaryOf where K: arc::Retain, diff --git a/cidre/src/cg/image/source.rs b/cidre/src/cg/image/source.rs index ac71ea10..d7f8b2a6 100644 --- a/cidre/src/cg/image/source.rs +++ b/cidre/src/cg/image/source.rs @@ -60,7 +60,10 @@ impl Src { #[doc(alias = "CGImageSourceCopyProperties")] #[inline] - pub fn props(&self, options: Option<&cf::Dictionary>) -> Option> { + pub fn props( + &self, + options: Option<&cf::Dictionary>, + ) -> Option>> { unsafe { CGImageSourceCopyProperties(self, options) } } @@ -70,7 +73,7 @@ impl Src { &self, index: usize, options: Option<&cf::Dictionary>, - ) -> Option> { + ) -> Option>> { unsafe { CGImageSourceCopyPropertiesAtIndex(self, index, options) } } @@ -119,13 +122,13 @@ extern "C-unwind" { fn CGImageSourceCopyProperties( isrc: &Src, options: Option<&cf::Dictionary>, - ) -> Option>; + ) -> Option>>; fn CGImageSourceCopyPropertiesAtIndex( isrc: &Src, index: usize, options: Option<&cf::Dictionary>, - ) -> Option>; + ) -> Option>>; fn CGImageSourceCreateImageAtIndex( isrc: &Src,