[vlc-commits] [Git][videolan/vlc][master] telegraf-rs: remove unnecessary UnsafeCell wrapper
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Thu Jun 11 12:40:28 UTC 2026
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
fce520b4 by Alexandre Janniaux at 2026-06-11T14:27:44+02:00
telegraf-rs: remove unnecessary UnsafeCell wrapper
Mutex<T> already uses UnsafeCell internally and provides identical
interior mutability. This simplifies the code and removes a layer of
indirection.
Reported-by: Romain Vimont <rom1v at videolabs.io>
- - - - -
1 changed file:
- modules/logger/telegraf-rs/src/lib.rs
Changes:
=====================================
modules/logger/telegraf-rs/src/lib.rs
=====================================
@@ -15,7 +15,7 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
-use std::{cell::UnsafeCell, sync::Mutex};
+use std::sync::Mutex;
use telegraf::{Client, IntoFieldData};
use vlcrs_core::tracer::{TraceValue, TracerCapability, TracerModuleLoader};
use vlcrs_macros::module;
@@ -34,7 +34,7 @@ impl<'a> IntoFieldData for TraceValueWrapper<'a> {
}
struct TelegrafTracer {
- endpoint: Mutex<UnsafeCell<telegraf::Client>>,
+ endpoint: Mutex<telegraf::Client>,
}
impl TracerCapability for TelegrafTracer {
@@ -45,7 +45,6 @@ impl TracerCapability for TelegrafTracer {
let endpoint_address =
std::env::var("VLC_TELEGRAF_ENDPOINT").unwrap_or(String::from("tcp://localhost:8094"));
let endpoint = Client::new(&endpoint_address)
- .map(UnsafeCell::new)
.map(Mutex::new)
.unwrap();
Some(Self { endpoint })
@@ -81,7 +80,7 @@ impl TracerCapability for TelegrafTracer {
};
let mut endpoint = self.endpoint.lock().unwrap();
- if let Err(err) = endpoint.get_mut().write_point(&p) {
+ if let Err(err) = endpoint.write_point(&p) {
match err {
telegraf::TelegrafError::IoError(e) => eprintln!("TelegrafTracer: IO Error: {}", e),
telegraf::TelegrafError::ConnectionError(s) => {
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/fce520b4b4965a64876b91c0c06a4307d61b60f2
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/fce520b4b4965a64876b91c0c06a4307d61b60f2
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list