pub struct FileAssociation {
pub ext: Vec<AssociationExt>,
pub content_types: Option<Vec<String>>,
pub name: Option<String>,
pub description: Option<String>,
pub role: BundleTypeRole,
pub mime_type: Option<String>,
pub rank: HandlerRank,
pub exported_type: Option<ExportedFileAssociation>,
pub android_intent_action_filters: Option<Vec<AndroidIntentAction>>,
}Expand description
File association
Fields§
§ext: Vec<AssociationExt>File extensions to associate with this app. e.g. ‘png’
content_types: Option<Vec<String>>Declare support to a file with the given content type. Maps to LSItemContentTypes on macOS.
This allows supporting any file format declared by another application that conforms to this type.
Declaration of new types can be done with Self::exported_type and linking to certain content types are done via ExportedFileAssociation::conforms_to.
name: Option<String>The name. Maps to CFBundleTypeName on macOS. Default to ext[0]
description: Option<String>The association description. Windows-only. It is displayed on the Type column on Windows Explorer.
role: BundleTypeRoleThe app’s role with respect to the type. Maps to CFBundleTypeRole on macOS.
mime_type: Option<String>The mime-type of the association, e.g. 'image/png' or 'text/plain'.
- Linux: written as
MimeType=in the.desktopfile. - macOS / iOS: added as
public.mime-typein theUTTypeTagSpecificationdictionary of theUTExportedTypeDeclarationsentry inInfo.plist. - Android: used as
android:mimeTypein the<data>element of an<intent-filter>inAndroidManifest.xml.
rank: HandlerRankThe ranking of this app among apps that declare themselves as editors or viewers of the given file type. Maps to LSHandlerRank on macOS.
exported_type: Option<ExportedFileAssociation>The exported type definition. Maps to a UTExportedTypeDeclarations entry on macOS.
You should define this if the associated file is a custom file type defined by your application.
android_intent_action_filters: Option<Vec<AndroidIntentAction>>Intent action filters for this file association.
By default all filters are used.
Implementations§
Source§impl FileAssociation
impl FileAssociation
Sourcepub fn infer_content_types(&self) -> HashSet<String>
pub fn infer_content_types(&self) -> HashSet<String>
Infers UTIs (Uniform Type Identifiers) from file extensions and mime types.
This is useful for macOS and iOS to automatically populate LSItemContentTypes
in the Info.plist for share sheet and file association support.
Returns a vector of UTIs that should be included in LSItemContentTypes.
Explicitly provided content types are included first, followed by inferred types.
Trait Implementations§
Source§impl Clone for FileAssociation
impl Clone for FileAssociation
Source§fn clone(&self) -> FileAssociation
fn clone(&self) -> FileAssociation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileAssociation
impl Debug for FileAssociation
Source§impl<'de> Deserialize<'de> for FileAssociation
impl<'de> Deserialize<'de> for FileAssociation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for FileAssociation
impl PartialEq for FileAssociation
Source§impl Serialize for FileAssociation
impl Serialize for FileAssociation
impl Eq for FileAssociation
impl StructuralPartialEq for FileAssociation
Auto Trait Implementations§
impl Freeze for FileAssociation
impl RefUnwindSafe for FileAssociation
impl Send for FileAssociation
impl Sync for FileAssociation
impl Unpin for FileAssociation
impl UnsafeUnpin for FileAssociation
impl UnwindSafe for FileAssociation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.