pub struct MDLabel { /* private fields */ }MDLabel only.Expand description
This is the type of a reference to an MDLabel.
See also Apple’s documentation
Implementations§
Source§impl MDLabel
impl MDLabel
Sourcepub unsafe fn new(
allocator: Option<&CFAllocator>,
display_name: Option<&CFString>,
kind: Option<&CFString>,
domain: MDLabelDomain,
) -> Option<CFRetained<MDLabel>>
Available on crate feature Metadata only.
pub unsafe fn new( allocator: Option<&CFAllocator>, display_name: Option<&CFString>, kind: Option<&CFString>, domain: MDLabelDomain, ) -> Option<CFRetained<MDLabel>>
Metadata only.Returns a label with the specified parameters. If there is already a label that exactly matches the parameters, a reference to the existing label will be returned; otherwise this will attempt to create a new label. A successful creation of a new private label definition will generate a kMDLabelAddedNotification. Note that this function can only create labels with “Private” visibility. Creating “Public” labels requires creating and installing a label bundle.
Parameter allocator: The CFAllocator which should be used to allocate memory for the label. This parameter may be NULL in which case the current default CFAllocator is used. Use kCFAllocatorNull to request a reference to an existing label only.
Parameter displayName: The label’s display name.
Parameter kind: The label’s kind string.
Parameter domain: The domain of the label (normally kMDLabelUserDomain).
Returns: An MDLabelRef, or NULL on failure.
§Safety
allocatormight not allowNone.display_namemight not allowNone.kindmight not allowNone.
Sourcepub unsafe fn attribute(
&self,
name: Option<&CFString>,
) -> Option<CFRetained<CFType>>
Available on crate feature Metadata only.
pub unsafe fn attribute( &self, name: Option<&CFString>, ) -> Option<CFRetained<CFType>>
Metadata only.Copy the value of the named attribute of a label.
Parameter label: The label.
Parameter name: The name of the desired attribute.
Returns: A CFTypeRef, or NULL on failure, or if the attribute does not exist, or if the attribute is not readable.
§Safety
name might not allow None.
Sourcepub unsafe fn attribute_name(&self) -> Option<CFRetained<CFString>>
Available on crate feature Metadata only.
pub unsafe fn attribute_name(&self) -> Option<CFRetained<CFString>>
Metadata only.Copy the MDItem attribute name of a label. The attribute name can be used in an MDQuery string to search for MDItems that have the label set. The value of the MDItem attribute is a CFDate corresponding to the time the label was set on the item.
Parameter label: The label.
Returns: A CFStringRef, or NULL on failure.
Sourcepub unsafe fn delete(&self) -> bool
Available on crate feature Metadata only.
pub unsafe fn delete(&self) -> bool
Metadata only.Deletes the user’s definition or override of the specified label from ~/Library/Metadata. Labels defined in bundles elsewhere in the filesystem cannot be deleted using this API. Deleting an override of a label merely makes the original definition of the label visible again and thus will generate a kMDLabelChangedNotification. A successful deletion of a private label definition will generate a kMDLabelRemovedNotification.
Parameter label: The label.
Returns: True if a label definition or override was successfully deleted.
Sourcepub unsafe fn set_attributes(&self, attrs: Option<&CFDictionary>) -> bool
Available on crate feature Metadata only.
pub unsafe fn set_attributes(&self, attrs: Option<&CFDictionary>) -> bool
Metadata only.Updates the attributes of the specified label. Labels defined in ~/Library/Metadata are modified directly. Labels defined in bundles elsewhere in the filesystem are overridden by creating a private copy of the label definition in ~/Library/Metadata. The updated attributes are then stored in the private copy. A successful call to MDLabelSetAttributes() will generate a kMDLabelChangedNotification.
Parameter label: The label.
Parameter attrs: A dictionary containing the attributes to be modified. To remove an attribute, include it in the dictionary with kCFNull as its value.
Returns: True if the label definition or override was successfully updated.
§Safety
attrsgenerics must be of the correct type.attrsmight not allowNone.
Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
Available on crate features SearchKit and SKDocument only.
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
SearchKit and SKDocument only.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
Available on crate features SearchKit and SKDocument only.
pub fn retain_count(&self) -> usize
SearchKit and SKDocument only.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 CFNumbers, small CFStrings 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 MDLabel
Available on crate feature Metadata only.
impl ConcreteType for MDLabel
Metadata only.Source§impl RefEncode for MDLabel
Available on crate feature Metadata only.
impl RefEncode for MDLabel
Metadata only.Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for MDLabel
Available on crate feature Metadata only.
impl Type for MDLabel
Metadata only.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 moreimpl Eq for MDLabel
Metadata only.