From a344f1c22a16421ffdcec18e7ef134117cda969a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20W=C3=BClker?= Date: Sun, 19 Jan 2025 02:43:57 +0100 Subject: [PATCH] Remove dependency on lazy static MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The gstreamer/webrtc crates were depending on lazy_static, but not using it. In the case of the streams crate, lazy_static can be replaced by the LazyLock struct from the standard library. (https://doc.rust-lang.org/std/sync/struct.LazyLock.html) Signed-off-by: Simon Wülker --- Cargo.lock | 3 --- backends/gstreamer/Cargo.toml | 1 - streams/Cargo.toml | 1 - streams/lib.rs | 3 --- streams/registry.rs | 11 ++++++----- webrtc/Cargo.toml | 3 +-- 6 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4821f05c..ee76ac24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2545,7 +2545,6 @@ dependencies = [ "gstreamer-video", "gstreamer-webrtc", "ipc-channel", - "lazy_static", "log 0.4.17", "mime 0.3.17", "once_cell", @@ -2613,7 +2612,6 @@ dependencies = [ name = "servo-media-streams" version = "0.1.0" dependencies = [ - "lazy_static", "uuid", ] @@ -2625,7 +2623,6 @@ version = "0.1.0" name = "servo-media-webrtc" version = "0.1.0" dependencies = [ - "lazy_static", "log 0.4.17", "servo-media-streams", "uuid", diff --git a/backends/gstreamer/Cargo.toml b/backends/gstreamer/Cargo.toml index 72d3bbb1..f8bb8e28 100644 --- a/backends/gstreamer/Cargo.toml +++ b/backends/gstreamer/Cargo.toml @@ -23,7 +23,6 @@ gst-webrtc = { workspace = true } gst-sdp = { workspace = true } gstreamer-sys = { workspace = true } ipc-channel = { workspace = true } -lazy_static = "1.2.0" log = "0.4" mime = "0.3.13" once_cell = "1.18.0" diff --git a/streams/Cargo.toml b/streams/Cargo.toml index d0bf0d86..0393d592 100644 --- a/streams/Cargo.toml +++ b/streams/Cargo.toml @@ -10,5 +10,4 @@ name = "servo_media_streams" path = "lib.rs" [dependencies] -lazy_static = "1.0" uuid = { version = "1.4", features = ["v4"] } diff --git a/streams/lib.rs b/streams/lib.rs index ba192984..769be994 100644 --- a/streams/lib.rs +++ b/streams/lib.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate lazy_static; - pub mod capture; pub mod device_monitor; pub mod registry; diff --git a/streams/registry.rs b/streams/registry.rs index 1215e222..9064aa88 100644 --- a/streams/registry.rs +++ b/streams/registry.rs @@ -1,12 +1,13 @@ use super::MediaStream; use std::collections::HashMap; -use std::sync::{Arc, Mutex}; +use std::sync::{Arc, LazyLock, Mutex}; use uuid::Uuid; -lazy_static! { - static ref MEDIA_STREAMS_REGISTRY: Mutex>>> = - Mutex::new(HashMap::new()); -} +type RegisteredMediaStream = Arc>; + +static MEDIA_STREAMS_REGISTRY: LazyLock>> = LazyLock::new(|| { + Mutex::new(HashMap::new()) +}); #[derive(Clone, Copy, Hash, Eq, PartialEq)] pub struct MediaStreamId(Uuid); diff --git a/webrtc/Cargo.toml b/webrtc/Cargo.toml index 5993a30a..8f77e278 100644 --- a/webrtc/Cargo.toml +++ b/webrtc/Cargo.toml @@ -9,8 +9,7 @@ edition = "2021" path = "lib.rs" [dependencies] -lazy_static = "1.0" -log = "0.4.6" +log = "0.4" uuid = { version = "1.4", features = ["v4"] } [dependencies.servo-media-streams]