diff --git a/Cargo.lock b/Cargo.lock index dca8ef4e4f1f703222253edb01e88b9fa95f43a1..4256b17fb61910c330f9bd6512a2f31ac8344909 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -230,9 +230,9 @@ checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anyhow" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" [[package]] name = "apply" @@ -828,9 +828,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.14" +version = "1.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9" +checksum = "c736e259eea577f443d5c86c304f9f4ae0295c43f3ba05c21f1d66b5f06001af" dependencies = [ "jobserver", "libc", @@ -1121,7 +1121,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -1143,7 +1143,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "quote", "syn 1.0.109", @@ -1209,7 +1209,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "almost", "cosmic-config", @@ -2173,9 +2173,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" +checksum = "5017294ff4bb30944501348f6f8e42e6ad28f42c8bbef7a74029aff064a4e3c2" dependencies = [ "atomic-waker", "bytes", @@ -2467,7 +2467,7 @@ dependencies = [ [[package]] name = "iced" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "dnd", "iced_accessibility", @@ -2485,7 +2485,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "accesskit", "accesskit_winit", @@ -2494,7 +2494,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "bitflags 2.8.0", "bytes", @@ -2517,7 +2517,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "futures", "iced_core", @@ -2543,7 +2543,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "bitflags 2.8.0", "bytemuck", @@ -2565,7 +2565,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2577,7 +2577,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "bytes", "dnd", @@ -2591,7 +2591,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "bytemuck", "cosmic-text", @@ -2607,7 +2607,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "as-raw-xcb-connection", "bitflags 2.8.0", @@ -2638,7 +2638,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "dnd", "iced_renderer", @@ -2655,7 +2655,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "dnd", "iced_futures", @@ -3236,7 +3236,7 @@ checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#3f25af87a3a41c53bdbd69878f32766bbcda2194" +source = "git+https://github.com/pop-os/libcosmic.git#8a0e74b189f53dae9b8001c6fa5cf1820b3ececb" dependencies = [ "apply", "ashpd 0.9.2", @@ -3296,7 +3296,7 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.8.0", "libc", - "redox_syscall 0.5.8", + "redox_syscall 0.5.9", ] [[package]] @@ -3374,9 +3374,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.25" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" [[package]] name = "lru" @@ -3524,9 +3524,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b" +checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" dependencies = [ "adler2", "simd-adler32", @@ -4085,7 +4085,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.8", + "redox_syscall 0.5.9", "smallvec", "windows-targets 0.52.6", ] @@ -4445,7 +4445,7 @@ checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.1", - "zerocopy 0.8.18", + "zerocopy 0.8.20", ] [[package]] @@ -4484,7 +4484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a88e0da7a2c97baa202165137c158d0a2e824ac465d13d81046727b34cb247d3" dependencies = [ "getrandom 0.3.1", - "zerocopy 0.8.18", + "zerocopy 0.8.20", ] [[package]] @@ -4535,9 +4535,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +checksum = "82b568323e98e49e2a0899dcee453dd679fae22d69adf9b11dd508d1549b7e2f" dependencies = [ "bitflags 2.8.0", ] @@ -4692,9 +4692,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.9" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e75ec5e92c4d8aede845126adc388046234541629e76029599ed35a003c7ed24" +checksum = "d34b5020fcdea098ef7d95e9f89ec15952123a4a039badd09fabebe9e963e839" dependencies = [ "cc", "cfg-if", @@ -4943,18 +4943,18 @@ checksum = "c2fdfc24bc566f839a2da4c4295b82db7d25a24253867d5c64355abb5799bdbe" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" dependencies = [ "proc-macro2", "quote", @@ -4963,9 +4963,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.138" +version = "1.0.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" dependencies = [ "indexmap", "itoa", @@ -5089,9 +5089,9 @@ checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "skrifa" -version = "0.26.5" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e92bf3f3af711d696eff796a4f28136927d40eb8108002b6f7919dc0cee27a5d" +checksum = "8cc1aa86c26dbb1b63875a7180aa0819709b33348eb5b1491e4321fae388179d" dependencies = [ "bytemuck", "read-fonts", @@ -5604,7 +5604,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.7.2", + "winnow 0.7.3", ] [[package]] @@ -5700,9 +5700,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "uds_windows" @@ -5754,9 +5754,9 @@ checksum = "1df77b101bcc4ea3d78dafc5ad7e4f58ceffe0b2b16bf446aeb50b6cb4157656" [[package]] name = "unicode-ident" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" +checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" [[package]] name = "unicode-linebreak" @@ -6690,9 +6690,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" +checksum = "0e7f4ea97f6f78012141bcdb6a216b2609f0979ada50b20ca5b52dde2eac2bb1" dependencies = [ "memchr", ] @@ -6951,7 +6951,7 @@ dependencies = [ "tracing", "uds_windows", "windows-sys 0.59.0", - "winnow 0.7.2", + "winnow 0.7.3", "xdg-home", "zbus_macros 5.5.0", "zbus_names 4.2.0", @@ -7030,7 +7030,7 @@ checksum = "7be68e64bf6ce8db94f63e72f0c7eb9a60d733f7e0499e628dfab0f84d6bcb97" dependencies = [ "serde", "static_assertions", - "winnow 0.7.2", + "winnow 0.7.3", "zvariant 5.4.0", ] @@ -7052,11 +7052,11 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.18" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79386d31a42a4996e3336b0919ddb90f81112af416270cff95b5f5af22b839c2" +checksum = "dde3bb8c68a8f3f1ed4ac9221aad6b10cece3e60a8e2ea54a6a2dec806d0084c" dependencies = [ - "zerocopy-derive 0.8.18", + "zerocopy-derive 0.8.20", ] [[package]] @@ -7072,9 +7072,9 @@ dependencies = [ [[package]] name = "zerocopy-derive" -version = "0.8.18" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76331675d372f91bf8d17e13afbd5fe639200b73d01f0fc748bb059f9cca2db7" +checksum = "eea57037071898bf96a6da35fd626f4f27e9cee3ead2a6c703cf09d472b2e700" dependencies = [ "proc-macro2", "quote", @@ -7183,7 +7183,7 @@ dependencies = [ "enumflags2", "serde", "static_assertions", - "winnow 0.7.2", + "winnow 0.7.3", "zvariant_derive 5.4.0", "zvariant_utils 3.2.0", ] @@ -7260,5 +7260,5 @@ dependencies = [ "serde", "static_assertions", "syn 2.0.98", - "winnow 0.7.2", + "winnow 0.7.3", ] diff --git a/Cargo.toml b/Cargo.toml index d65093e62a9a598b3038b497ec4893915c95a714..9e34da97ab5278c9ae11cec6c74583fe77fc519f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ members = [ ] [workspace.package] -edition = "2021" +edition = "2024" authors = [ "Maëlle MARTIN <maelle.martin@proton.me>", "Louis GOYARD <elliu@hashi.re>", @@ -21,7 +21,7 @@ authors = [ "Étienne BRATEAU <etienne.brateau@gmail.com>", "Tristan DEROUET <tristan.derouet@gmail.com>", ] -rust-version = '1.80' +rust-version = '1.85' version = '8.0.1' license = 'MIT' diff --git a/lektord/src/c_wrapper/abort.rs b/lektord/src/c_wrapper/abort.rs index 2dd284464ae030e52ee4e156c754128284d9ba2d..ebebe8180e1bfff5494c6537d2d69954c7d5f682 100644 --- a/lektord/src/c_wrapper/abort.rs +++ b/lektord/src/c_wrapper/abort.rs @@ -1,6 +1,6 @@ /// So the C/C++ part of the code can call the Rust panic and unwind things. With that tokio can /// catch an abort and stay alive. -#[export_name = "___lkt_abort"] +#[unsafe(export_name = "___lkt_abort")] pub(super) extern "C" fn lkt_abort() { panic!() } diff --git a/lektord/src/c_wrapper/commands.rs b/lektord/src/c_wrapper/commands.rs index d2294e7b9e38c460ff8eb124eac5af3505360c90..42fba66a3d0d2a1f0a61d0612ad3a645afb1e1d2 100644 --- a/lektord/src/c_wrapper/commands.rs +++ b/lektord/src/c_wrapper/commands.rs @@ -1,13 +1,13 @@ use super::{PlayerEvent, STATE}; -use anyhow::{bail, Context, Error, Result}; +use anyhow::{Context, Error, Result, bail}; use lektor_payloads::{KId, PlayState}; use std::{ffi::*, path::Path, ptr::NonNull}; /// Safe wrapper around `mod_stop_playback`. Stops the playback. Same as [player_toggle_pause], don't update /// the database yourself, it will be done by a callback chain. pub(crate) fn player_stop() -> Result<()> { - extern "C" { - fn mod_stop_playback() -> c_int; + unsafe extern "C" { + unsafe fn mod_stop_playback() -> c_int; } (0 == unsafe { mod_stop_playback() }) .then_some(()) @@ -18,8 +18,8 @@ pub(crate) fn player_stop() -> Result<()> { /// [player_toggle_pause], don't update the database yourself, it will be done by a callback chain /// latter. pub(crate) fn player_set_paused(state: PlayState) -> Result<()> { - extern "C" { - fn mod_set_paused(_: c_int) -> c_int; + unsafe extern "C" { + unsafe fn mod_set_paused(_: c_int) -> c_int; } let paused = match state { PlayState::Stop => bail!("can't convert stop into a paused flag"), @@ -35,8 +35,8 @@ pub(crate) fn player_set_paused(state: PlayState) -> Result<()> { /// the database in addition to this call, the database will be updated when the change will be /// made in the mpv player. pub(crate) fn player_toggle_pause() -> Result<()> { - extern "C" { - fn mod_toggle_pause() -> c_int; + unsafe extern "C" { + unsafe fn mod_toggle_pause() -> c_int; } (0 == unsafe { mod_toggle_pause() }) .then_some(()) @@ -46,8 +46,8 @@ pub(crate) fn player_toggle_pause() -> Result<()> { /// Safe wrapper around `mod_set_position` Set the position in the player module. #[allow(dead_code)] pub(crate) fn player_set_position(position: i64) -> Result<()> { - extern "C" { - fn mod_set_position(_: c_int) -> c_int; + unsafe extern "C" { + unsafe fn mod_set_position(_: c_int) -> c_int; } (0 == unsafe { mod_set_position(c_int::try_from(position)?) }) .then_some(()) @@ -56,8 +56,8 @@ pub(crate) fn player_set_position(position: i64) -> Result<()> { /// Safe wrapper around `mod_get_duration` Get the duration of the current playing file. pub(crate) fn player_get_duration() -> Result<i64> { - extern "C" { - fn mod_get_duration(_: NonNull<c_int>) -> c_int; + unsafe extern "C" { + unsafe fn mod_get_duration(_: NonNull<c_int>) -> c_int; } let mut duration: c_int = 0; (0 == unsafe { mod_get_duration(NonNull::new_unchecked((&mut duration) as *mut _)) }) @@ -67,8 +67,8 @@ pub(crate) fn player_get_duration() -> Result<i64> { /// Safe wrapper around `mod_get_elapsed` Get the duration since the begin of the kara. pub(crate) fn player_get_elapsed() -> Result<i64> { - extern "C" { - fn mod_get_elapsed(_: NonNull<c_int>) -> c_int; + unsafe extern "C" { + unsafe fn mod_get_elapsed(_: NonNull<c_int>) -> c_int; } let mut elapsed: c_int = 0; (0 == unsafe { mod_get_elapsed(NonNull::new_unchecked((&mut elapsed) as *mut _)) }) @@ -78,8 +78,8 @@ pub(crate) fn player_get_elapsed() -> Result<i64> { /// Safe wrapper around `mod_load_file` Tell the player to load a file by its path. pub(crate) fn player_load_file(path: impl AsRef<Path>, id: KId) -> Result<()> { - extern "C" { - fn mod_load_file(_: NonNull<c_char>, _: u64) -> c_int; + unsafe extern "C" { + unsafe fn mod_load_file(_: NonNull<c_char>, _: u64) -> c_int; } let path = path .as_ref() @@ -94,8 +94,8 @@ pub(crate) fn player_load_file(path: impl AsRef<Path>, id: KId) -> Result<()> { /// Safe wrapper around `mod_set_volume` Set the volume of the player. #[allow(dead_code)] pub(crate) fn player_set_playback_volume(vol: i64) -> Result<()> { - extern "C" { - fn mod_set_volume(_: c_int) -> c_int; + unsafe extern "C" { + unsafe fn mod_set_volume(_: c_int) -> c_int; } let vol = c_int::try_from(vol)?.clamp(0, 100); (0 == unsafe { mod_set_volume(vol) }) @@ -120,19 +120,19 @@ fn send_msg(msg: PlayerEvent) { } /// Set the play state in the database, the signal is send from the player. -#[no_mangle] +#[unsafe(no_mangle)] pub(super) extern "C" fn lkt_toggle_play_state(state: c_int) { send_msg(PlayerEvent::SetPlayState(state)) } /// The player needs to play the next kara in the queue. -#[no_mangle] +#[unsafe(no_mangle)] pub(super) extern "C" fn lkt_play_next() { send_msg(PlayerEvent::PlayNext) } /// The player needs to play the previous kara in the queue or in the history. -#[no_mangle] +#[unsafe(no_mangle)] pub(super) extern "C" fn lkt_play_prev() { send_msg(PlayerEvent::PlayPrev) } diff --git a/lektord/src/c_wrapper/loging.rs b/lektord/src/c_wrapper/loging.rs index 1ef1f3f26ce4cfd6d65d940ec1aac7aa6d4ac026..79fc559da35b8b0e2966dc3289fa031bb7105e07 100644 --- a/lektord/src/c_wrapper/loging.rs +++ b/lektord/src/c_wrapper/loging.rs @@ -6,7 +6,7 @@ use std::{ /// # Safety /// This function is intended to be called by `___lkt_log` with valid CStrings, i.e., the strings /// must be null-terminated. Note that from the C-side of things, you can't pass null pointers. -#[export_name = "___lkt_log_rs"] +#[unsafe(export_name = "___lkt_log_rs")] #[inline(never)] pub unsafe extern "C" fn lkt_log_rs( log_level: c_int, diff --git a/lektord/src/c_wrapper/mod.rs b/lektord/src/c_wrapper/mod.rs index d744f2a6764c3ec091a41e1ad3afff0f5e450008..3131c8cef69902b8a4f9f5845c18094dba2c7ac0 100644 --- a/lektord/src/c_wrapper/mod.rs +++ b/lektord/src/c_wrapper/mod.rs @@ -1,7 +1,7 @@ //! Interface with the C/C++ part of the code. The only place we allow unsafe code in this crate. use crate::LektorStatePtr; -use anyhow::{ensure, Context as _, Result}; +use anyhow::{Context as _, Result, ensure}; use lektor_utils::config::LektorPlayerConfig; use std::{ ffi::*, @@ -57,10 +57,10 @@ pub(crate) fn init_player_module(ptr: LektorStatePtr, config: LektorPlayerConfig toggle: extern "C" fn(c_int), } - extern "C" { - fn mod_new(_: *const FunctionTable) -> c_int; - fn mod_set_msg_options(_: NonNull<c_char>, _: u64, _: u64) -> c_int; - fn mod_set_force_x11(_: bool) -> c_int; + unsafe extern "C" { + unsafe fn mod_new(_: *const FunctionTable) -> c_int; + unsafe fn mod_set_msg_options(_: NonNull<c_char>, _: u64, _: u64) -> c_int; + unsafe fn mod_set_force_x11(_: bool) -> c_int; } let LektorPlayerConfig { @@ -76,7 +76,7 @@ pub(crate) fn init_player_module(ptr: LektorStatePtr, config: LektorPlayerConfig let weak_ptr = Arc::downgrade(&ptr); let handle = tokio::task::spawn(async move { while let Some(event) = receiver.recv().await { - use {lektor_payloads::PlayState as PS, LktPlayState as LPS}; + use {LktPlayState as LPS, lektor_payloads::PlayState as PS}; match event { PlayerEvent::SetPlayState(state) => match LktPlayState::try_from(state) { Ok(state @ (LPS::Stop | LPS::Play | LPS::Pause)) => { @@ -155,11 +155,12 @@ pub(crate) fn init_player_module(ptr: LektorStatePtr, config: LektorPlayerConfig /// Unregister the current lektor state, done before exiting to release the strong reference to the /// state. Will return false if no state was present. pub async fn close_player_module() -> Result<()> { - extern "C" { - fn mod_close() -> c_int; + unsafe extern "C" { + unsafe fn mod_close() -> c_int; } - let (sender, handle) = (STATE.write().ok().context("failed to lock state mutex")?) + let (sender, handle) = (STATE.write().ok()) + .context("failed to lock state mutex")? .take() .context("the player state wasn't initialized")?;