Skip to content

Commit b10afc5

Browse files
Replace objc with objc2 to fix clippy warnings
1 parent 9649e07 commit b10afc5

File tree

3 files changed

+22
-41
lines changed

3 files changed

+22
-41
lines changed

Cargo.lock

+4-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mullvad-daemon/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ simple-signal = "1.1"
6262
talpid-dbus = { path = "../talpid-dbus" }
6363

6464
[target.'cfg(target_os="macos")'.dependencies]
65-
objc = { version = "0.2.7", features = ["exception", "verify_message"] }
65+
objc2 = { version = "0.5.2", features = ["exception"] }
6666

6767
[target.'cfg(windows)'.dependencies]
6868
ctrlc = "3.0"

mullvad-daemon/src/macos_launch_daemon.rs

+17-11
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
//! must be checked so that the user can be directed to approve the launch
66
//! daemon in the system settings.
77
8-
use objc::{class, msg_send, sel, sel_impl};
8+
use libc::c_longlong;
9+
use objc2::{class, msg_send, runtime::AnyObject, Encode, Encoding, RefEncode};
910
use std::ffi::CStr;
1011

11-
type Id = *mut objc::runtime::Object;
12+
type Id = *mut AnyObject;
1213

1314
// Framework that contains `SMAppService`.
1415
#[link(name = "ServiceManagement", kind = "framework")]
@@ -18,18 +19,23 @@ extern "C" {}
1819
#[repr(C)]
1920
#[derive(Debug)]
2021
struct NSOperatingSystemVersion {
21-
major_version: libc::c_longlong,
22-
minor_version: libc::c_longlong,
23-
patch_version: libc::c_longlong,
22+
major_version: c_longlong,
23+
minor_version: c_longlong,
24+
patch_version: c_longlong,
2425
}
2526

26-
/// Implement Objective-C type encoding for the struct. Allows the `objc` crate
27+
/// Implement Objective-C type encoding for the struct. Allows the `objc2` crate
2728
/// to perform function signature matching before performing calls into the Objective-C
28-
/// runtime. This is needed to be able to enable the `verify_message` feature on `objc`.
29-
unsafe impl objc::Encode for NSOperatingSystemVersion {
30-
fn encode() -> objc::Encoding {
31-
unsafe { objc::Encoding::from_str("{?=qqq}") }
32-
}
29+
/// runtime.
30+
unsafe impl Encode for NSOperatingSystemVersion {
31+
const ENCODING: Encoding = Encoding::Struct(
32+
"NSOperatingSystemVersion",
33+
&[Encoding::LongLong, Encoding::LongLong, Encoding::LongLong],
34+
);
35+
}
36+
37+
unsafe impl RefEncode for NSOperatingSystemVersion {
38+
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
3339
}
3440

3541
/// Authorization status of the Mullvad daemon.

0 commit comments

Comments
 (0)