rust_macios/foundation/
ns_bundle.rs1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4 object,
5 objective_c_runtime::{
6 id,
7 macros::interface_impl,
8 traits::{FromId, PNSObject},
9 },
10};
11
12use super::{NSArray, NSDictionary, NSString};
13
14object! {
15 unsafe pub struct NSBundle;
17}
18
19#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
20#[repr(usize)]
21pub enum MachOArchitecture {
22 ARM64 = 0x0100000c,
23 I386 = 0x00000007,
24 X86_64 = 0x01000007,
25 PPC = 0x00000012,
26 PPC64 = 0x01000012,
27}
28
29#[interface_impl(NSObject)]
30impl NSBundle {
31 #[property]
35 pub fn main_bundle() -> NSBundle {
36 unsafe { NSBundle::from_id(msg_send![Self::m_class(), mainBundle]) }
37 }
38
39 #[property]
41 pub fn all_frameworks() -> NSArray<NSBundle> {
42 unsafe { NSArray::from_id(msg_send![Self::m_class(), allFrameworks]) }
43 }
44
45 #[property]
47 pub fn all_bundles() -> NSArray<NSBundle> {
48 unsafe { NSArray::from_id(msg_send![Self::m_class(), allBundles]) }
49 }
50
51 #[property]
53 pub fn resource_path(&self) -> NSString {
54 unsafe { NSString::from_id(msg_send![self.m_self(), resourcePath]) }
55 }
56
57 #[property]
59 pub fn executable_path(&self) -> NSString {
60 unsafe { NSString::from_id(msg_send![self.m_self(), executablePath]) }
61 }
62
63 #[property]
65 pub fn bundle_path(&self) -> NSString {
66 unsafe { NSString::from_id(msg_send![self.m_self(), bundlePath]) }
67 }
68
69 #[property]
71 pub fn bundle_identifier(&self) -> NSString {
72 unsafe { NSString::from_id(msg_send![self.m_self(), bundleIdentifier]) }
73 }
74
75 #[property]
77 pub fn info_dictionary(&self) -> NSDictionary<NSString, id> {
78 unsafe { NSDictionary::from_id(msg_send![self.m_self(), infoDictionary]) }
79 }
80}