From 850331699a3317fd0c55103f9f2dc540282ee005 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Wed, 27 Nov 2024 18:31:45 +0530 Subject: [PATCH] net/quinn: Use LazyLock instead of once_cell::Lazy Part-of: --- net/quinn/src/quinnwtclientsrc/imp.rs | 11 +++++------ net/quinn/src/quinnwtserversink/imp.rs | 13 ++++++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/net/quinn/src/quinnwtclientsrc/imp.rs b/net/quinn/src/quinnwtclientsrc/imp.rs index 4c32984e..32e924a3 100644 --- a/net/quinn/src/quinnwtclientsrc/imp.rs +++ b/net/quinn/src/quinnwtclientsrc/imp.rs @@ -21,18 +21,17 @@ use gst::{glib, prelude::*, subclass::prelude::*}; use gst_base::prelude::*; use gst_base::subclass::base_src::CreateSuccess; use gst_base::subclass::prelude::*; -use once_cell::sync::Lazy; use quinn::{Connection, ConnectionError, TransportConfig}; use rustls::server; use std::borrow::Borrow; use std::fmt::Error; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::path::PathBuf; -use std::sync::Mutex; +use std::sync::{LazyLock, Mutex}; use tokio::net::lookup_host; use web_transport_quinn::{ReadError, RecvStream, Session, SessionError, ALPN}; -static CAT: Lazy = Lazy::new(|| { +static CAT: LazyLock = LazyLock::new(|| { gst::DebugCategory::new( "quinnwtclientsrc", gst::DebugColorFlags::empty(), @@ -106,7 +105,7 @@ impl GstObjectImpl for QuinnWebTransportClientSrc {} impl ElementImpl for QuinnWebTransportClientSrc { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { - static ELEMENT_METADATA: Lazy = Lazy::new(|| { + static ELEMENT_METADATA: LazyLock = LazyLock::new(|| { gst::subclass::ElementMetadata::new( "Quinn WebTransport Client Source", "Source/Network/QUIC", @@ -118,7 +117,7 @@ impl ElementImpl for QuinnWebTransportClientSrc { } fn pad_templates() -> &'static [gst::PadTemplate] { - static PAD_TEMPLATES: Lazy> = Lazy::new(|| { + static PAD_TEMPLATES: LazyLock> = LazyLock::new(|| { let src_pad_template = gst::PadTemplate::new( "src", gst::PadDirection::Src, @@ -143,7 +142,7 @@ impl ObjectImpl for QuinnWebTransportClientSrc { } fn properties() -> &'static [glib::ParamSpec] { - static PROPERTIES: Lazy> = Lazy::new(|| { + static PROPERTIES: LazyLock> = LazyLock::new(|| { vec![ glib::ParamSpecBoxed::builder::("caps") .nick("caps") diff --git a/net/quinn/src/quinnwtserversink/imp.rs b/net/quinn/src/quinnwtserversink/imp.rs index 913aa84e..a8a09b3a 100644 --- a/net/quinn/src/quinnwtserversink/imp.rs +++ b/net/quinn/src/quinnwtserversink/imp.rs @@ -20,14 +20,13 @@ use bytes::Bytes; use futures::future; use gst::{glib, prelude::*, subclass::prelude::*}; use gst_base::subclass::prelude::*; -use once_cell::sync::Lazy; use quinn::{Connection, TransportConfig}; use web_transport_quinn::{Request, SendStream, Session}; - use std::path::PathBuf; -use std::sync::Mutex; +use std::sync::{LazyLock, Mutex}; +use web_transport_quinn::{Request, SendStream, Session}; -static CAT: Lazy = Lazy::new(|| { +static CAT: LazyLock = LazyLock::new(|| { gst::DebugCategory::new( "quinnwtserversink", gst::DebugColorFlags::empty(), @@ -101,7 +100,7 @@ impl GstObjectImpl for QuinnWebTransportServerSink {} impl ElementImpl for QuinnWebTransportServerSink { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { - static ELEMENT_METADATA: Lazy = Lazy::new(|| { + static ELEMENT_METADATA: LazyLock = LazyLock::new(|| { gst::subclass::ElementMetadata::new( "Quinn WebTransport Server Sink", "Source/Network/WebTransport", @@ -113,7 +112,7 @@ impl ElementImpl for QuinnWebTransportServerSink { } fn pad_templates() -> &'static [gst::PadTemplate] { - static PAD_TEMPLATES: Lazy> = Lazy::new(|| { + static PAD_TEMPLATES: LazyLock> = LazyLock::new(|| { let sink_pad_template = gst::PadTemplate::new( "sink", gst::PadDirection::Sink, @@ -157,7 +156,7 @@ impl ObjectImpl for QuinnWebTransportServerSink { } fn properties() -> &'static [glib::ParamSpec] { - static PROPERTIES: Lazy> = Lazy::new(|| { + static PROPERTIES: LazyLock> = LazyLock::new(|| { vec![ glib::ParamSpecString::builder("server-name") .nick("QUIC server name")