Fix various new clippy warnings

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1203>
This commit is contained in:
Sebastian Dröge 2023-01-25 10:09:45 +02:00
parent 7efc22ebc9
commit f24b38470b
93 changed files with 228 additions and 259 deletions

View file

@ -21,7 +21,7 @@ use gst::{element_error, prelude::*};
mod examples_common; mod examples_common;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")]
struct ErrorMessage { struct ErrorMessage {
src: glib::GString, src: glib::GString,
error: glib::Error, error: glib::Error,
@ -107,7 +107,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
}) })
.sum(); .sum();
let rms = (sum / (samples.len() as f64)).sqrt(); let rms = (sum / (samples.len() as f64)).sqrt();
println!("rms: {}", rms); println!("rms: {rms}");
Ok(gst::FlowSuccess::Ok) Ok(gst::FlowSuccess::Ok)
}) })
@ -153,7 +153,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
fn example_main() { fn example_main() {
match create_pipeline().and_then(main_loop) { match create_pipeline().and_then(main_loop) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -18,7 +18,7 @@ use gst::prelude::*;
mod examples_common; mod examples_common;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")]
struct ErrorMessage { struct ErrorMessage {
src: glib::GString, src: glib::GString,
error: glib::Error, error: glib::Error,
@ -75,7 +75,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
return; return;
} }
println!("Producing frame {}", i); println!("Producing frame {i}");
let r = if i % 2 == 0 { 0 } else { 255 }; let r = if i % 2 == 0 { 0 } else { 255 };
let g = if i % 3 == 0 { 0 } else { 255 }; let g = if i % 3 == 0 { 0 } else { 255 };
@ -169,7 +169,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
fn example_main() { fn example_main() {
match create_pipeline().and_then(main_loop) { match create_pipeline().and_then(main_loop) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -117,10 +117,7 @@ fn example_main() {
Some(pipeline) => pipeline, Some(pipeline) => pipeline,
None => return glib::Continue(false), None => return glib::Continue(false),
}; };
println!( println!("Sending custom event to the pipeline with send_eos={send_eos}");
"Sending custom event to the pipeline with send_eos={}",
send_eos
);
let ev = ExampleCustomEvent::new(*send_eos); let ev = ExampleCustomEvent::new(*send_eos);
if !pipeline.send_event(ev) { if !pipeline.send_event(ev) {
println!("Warning: Failed to send custom event"); println!("Warning: Failed to send custom event");

View file

@ -200,13 +200,13 @@ fn example_main() {
return; return;
} }
println!("Producing buffer {}", i); println!("Producing buffer {i}");
// Add a custom meta with a label to this buffer. // Add a custom meta with a label to this buffer.
let mut buffer = gst::Buffer::new(); let mut buffer = gst::Buffer::new();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
custom_meta::CustomMeta::add(buffer, format!("This is buffer {}", i)); custom_meta::CustomMeta::add(buffer, format!("This is buffer {i}"));
} }
i += 1; i += 1;

View file

@ -33,7 +33,7 @@ fn example_main() {
if let Some(gst::ParseError::NoSuchElement) = err.kind::<gst::ParseError>() { if let Some(gst::ParseError::NoSuchElement) = err.kind::<gst::ParseError>() {
println!("Missing element(s): {:?}", context.missing_elements()); println!("Missing element(s): {:?}", context.missing_elements());
} else { } else {
println!("Failed to parse pipeline: {}", err); println!("Failed to parse pipeline: {err}");
} }
process::exit(-1) process::exit(-1)
@ -74,7 +74,7 @@ fn example_main() {
println!("Dumping debug logs\n"); println!("Dumping debug logs\n");
for s in gst::debug_ring_buffer_logger_get_logs().iter() { for s in gst::debug_ring_buffer_logger_get_logs().iter() {
println!("{}\n------------------", s); println!("{s}\n------------------");
} }
} }

View file

@ -42,7 +42,7 @@ use gst::{element_error, element_warning, prelude::*};
mod examples_common; mod examples_common;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")]
struct ErrorMessage { struct ErrorMessage {
src: glib::GString, src: glib::GString,
error: glib::Error, error: glib::Error,
@ -264,6 +264,6 @@ fn main() {
// (but not necessary in normal Cocoa applications where this is set up automatically) // (but not necessary in normal Cocoa applications where this is set up automatically)
match examples_common::run(example_main) { match examples_common::run(example_main) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -18,7 +18,7 @@ use gst_pbutils::{prelude::*, DiscovererInfo, DiscovererStreamInfo};
mod examples_common; mod examples_common;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Discoverer error {}", _0)] #[display(fmt = "Discoverer error {_0}")]
struct DiscovererError(#[error(not(source))] &'static str); struct DiscovererError(#[error(not(source))] &'static str);
fn print_tags(info: &DiscovererInfo) { fn print_tags(info: &DiscovererInfo) {
@ -27,7 +27,7 @@ fn print_tags(info: &DiscovererInfo) {
let tags = info.tags(); let tags = info.tags();
match tags { match tags {
Some(taglist) => { Some(taglist) => {
println!(" {}", taglist); // FIXME use an iterator println!(" {taglist}"); // FIXME use an iterator
} }
None => { None => {
println!(" no tags"); println!(" no tags");
@ -42,7 +42,7 @@ fn print_stream_info(stream: &DiscovererStreamInfo) {
Some(caps) => caps.to_string(), Some(caps) => caps.to_string(),
None => String::from("--"), None => String::from("--"),
}; };
println!(" Format: {}", caps_str); println!(" Format: {caps_str}");
} }
fn print_discoverer_info(info: &DiscovererInfo) -> Result<(), Error> { fn print_discoverer_info(info: &DiscovererInfo) -> Result<(), Error> {
@ -85,7 +85,7 @@ fn run_discoverer() -> Result<(), Error> {
fn example_main() { fn example_main() {
match run_discoverer() { match run_discoverer() {
Ok(_) => (), Ok(_) => (),
Err(e) => eprintln!("Error: {}", e), Err(e) => eprintln!("Error: {e}"),
} }
} }

View file

@ -26,7 +26,7 @@ use gst_pbutils::prelude::*;
mod examples_common; mod examples_common;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")]
struct ErrorMessage { struct ErrorMessage {
src: glib::GString, src: glib::GString,
error: glib::Error, error: glib::Error,
@ -281,6 +281,6 @@ fn main() {
// (but not necessary in normal Cocoa applications where this is set up automatically) // (but not necessary in normal Cocoa applications where this is set up automatically)
match examples_common::run(example_main) { match examples_common::run(example_main) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -341,7 +341,7 @@ fn main() {
// (but not necessary in normal Cocoa applications where this is set up automatically) // (but not necessary in normal Cocoa applications where this is set up automatically)
match examples_common::run(example_main) { match examples_common::run(example_main) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -63,7 +63,7 @@ fn configure_pipeline(pipeline: &ges::Pipeline, output_name: &str) {
.build(); .build();
// Apply the EncodingProfile to the pipeline, and set it to render mode // Apply the EncodingProfile to the pipeline, and set it to render mode
let output_uri = format!("{}.webm", output_name); let output_uri = format!("{output_name}.webm");
pipeline pipeline
.set_render_settings(&output_uri, &container_profile) .set_render_settings(&output_uri, &container_profile)
.expect("Failed to set render settings"); .expect("Failed to set render settings");
@ -168,7 +168,7 @@ fn example_main() {
match main_loop(input_uri, output) { match main_loop(input_uri, output) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -166,7 +166,7 @@ fn example_main() {
let glfilter = mirror::GLMirrorFilter::new(Some("foo")); let glfilter = mirror::GLMirrorFilter::new(Some("foo"));
App::new(Some(glfilter.as_ref())) App::new(Some(glfilter.as_ref()))
.and_then(main_loop) .and_then(main_loop)
.unwrap_or_else(|e| eprintln!("Error! {}", e)) .unwrap_or_else(|e| eprintln!("Error! {e}"))
} }
fn main() { fn main() {

View file

@ -10,7 +10,7 @@ pub mod examples_common;
fn example_main() { fn example_main() {
App::new(None) App::new(None)
.and_then(main_loop) .and_then(main_loop)
.unwrap_or_else(|e| eprintln!("Error! {}", e)) .unwrap_or_else(|e| eprintln!("Error! {e}"))
} }
fn main() { fn main() {

View file

@ -53,7 +53,7 @@ fn set_window_handle(video_overlay: &gst_video::VideoOverlay, gdk_window: &gdk::
video_overlay.set_window_handle(xid as usize); video_overlay.set_window_handle(xid as usize);
} }
} else { } else {
println!("Add support for display type '{}'", display_type_name); println!("Add support for display type '{display_type_name}'");
process::exit(-1); process::exit(-1);
} }
} }

View file

@ -33,7 +33,7 @@ fn example_main() {
if let Some(gst::ParseError::NoSuchElement) = err.kind::<gst::ParseError>() { if let Some(gst::ParseError::NoSuchElement) = err.kind::<gst::ParseError>() {
println!("Missing element(s): {:?}", context.missing_elements()); println!("Missing element(s): {:?}", context.missing_elements());
} else { } else {
println!("Failed to parse pipeline: {}", err); println!("Failed to parse pipeline: {err}");
} }
process::exit(-1) process::exit(-1)

View file

@ -22,7 +22,7 @@ use pango::prelude::*;
mod examples_common; mod examples_common;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")]
struct ErrorMessage { struct ErrorMessage {
src: glib::GString, src: glib::GString,
error: glib::Error, error: glib::Error,
@ -293,7 +293,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
fn example_main() { fn example_main() {
match create_pipeline().and_then(main_loop) { match create_pipeline().and_then(main_loop) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -66,7 +66,7 @@ fn example_main() {
}) })
.sum(); .sum();
let rms = (sum / (samples.len() as f64)).sqrt(); let rms = (sum / (samples.len() as f64)).sqrt();
println!("rms: {}", rms); println!("rms: {rms}");
} }
gst::PadProbeReturn::Ok gst::PadProbeReturn::Ok

View file

@ -25,7 +25,7 @@ use pango::prelude::*;
mod examples_common; mod examples_common;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")]
struct ErrorMessage { struct ErrorMessage {
src: glib::GString, src: glib::GString,
error: glib::Error, error: glib::Error,
@ -237,7 +237,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
fn example_main() { fn example_main() {
match create_pipeline().and_then(main_loop) { match create_pipeline().and_then(main_loop) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -51,7 +51,7 @@ fn example_main() {
match main_loop(uri) { match main_loop(uri) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -65,7 +65,7 @@ fn example_main() {
.get::<i32>() .get::<i32>()
.expect("playbin \"audio-tags-changed\" signal values[1]"); .expect("playbin \"audio-tags-changed\" signal values[1]");
println!("audio tags of audio stream {} changed:", idx); println!("audio tags of audio stream {idx} changed:");
// HELP: is this correct? // HELP: is this correct?
// We were only notified about the change of metadata. If we want to do // We were only notified about the change of metadata. If we want to do

View file

@ -76,7 +76,7 @@ fn example_main() {
match main_loop(uri) { match main_loop(uri) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -9,19 +9,19 @@ use anyhow::Error;
use derive_more::{Display, Error}; use derive_more::{Display, Error};
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "No such pad {} in {}", _0, _1)] #[display(fmt = "No such pad {_0} in {_1}")]
struct NoSuchPad(#[error(not(source))] &'static str, String); struct NoSuchPad(#[error(not(source))] &'static str, String);
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Unknown payload type {}", _0)] #[display(fmt = "Unknown payload type {_0}")]
struct UnknownPT(#[error(not(source))] u32); struct UnknownPT(#[error(not(source))] u32);
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Usage: {} (play | record) DROP_PROBABILITY", _0)] #[display(fmt = "Usage: {_0} (play | record) DROP_PROBABILITY")]
struct UsageError(#[error(not(source))] String); struct UsageError(#[error(not(source))] String);
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")]
struct ErrorMessage { struct ErrorMessage {
src: glib::GString, src: glib::GString,
error: glib::Error, error: glib::Error,
@ -275,6 +275,6 @@ fn example_main() -> Result<(), Error> {
fn main() { fn main() {
match examples_common::run(example_main) { match examples_common::run(example_main) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -9,15 +9,15 @@ use anyhow::Error;
use derive_more::{Display, Error}; use derive_more::{Display, Error};
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "No such pad {} in {}", _0, _1)] #[display(fmt = "No such pad {_0} in {_1}")]
struct NoSuchPad(&'static str, String); struct NoSuchPad(&'static str, String);
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Usage: {} URI FEC_PERCENTAGE", _0)] #[display(fmt = "Usage: {_0} URI FEC_PERCENTAGE")]
struct UsageError(#[error(not(source))] String); struct UsageError(#[error(not(source))] String);
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")]
struct ErrorMessage { struct ErrorMessage {
src: glib::GString, src: glib::GString,
error: glib::Error, error: glib::Error,
@ -201,6 +201,6 @@ fn example_main() -> Result<(), Error> {
fn main() { fn main() {
match examples_common::run(example_main) { match examples_common::run(example_main) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -19,7 +19,7 @@ mod examples_common;
struct NoMountPoints; struct NoMountPoints;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Usage: {} LAUNCH_LINE", _0)] #[display(fmt = "Usage: {_0} LAUNCH_LINE")]
struct UsageError(#[error(not(source))] String); struct UsageError(#[error(not(source))] String);
fn main_loop() -> Result<(), Error> { fn main_loop() -> Result<(), Error> {
@ -152,6 +152,6 @@ fn example_main() -> Result<(), Error> {
fn main() { fn main() {
match examples_common::run(example_main) { match examples_common::run(example_main) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -20,7 +20,7 @@ mod examples_common;
struct NoMountPoints; struct NoMountPoints;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Usage: {} LAUNCH_LINE", _0)] #[display(fmt = "Usage: {_0} LAUNCH_LINE")]
struct UsageError(#[error(not(source))] String); struct UsageError(#[error(not(source))] String);
fn main_loop() -> Result<(), Error> { fn main_loop() -> Result<(), Error> {
@ -252,7 +252,7 @@ mod server {
fn client_connected(&self, client: &gst_rtsp_server::RTSPClient) { fn client_connected(&self, client: &gst_rtsp_server::RTSPClient) {
self.parent_client_connected(client); self.parent_client_connected(client);
println!("Client {:?} connected", client); println!("Client {client:?} connected");
} }
} }
} }
@ -301,7 +301,7 @@ mod client {
fn closed(&self) { fn closed(&self) {
let client = self.obj(); let client = self.obj();
self.parent_closed(); self.parent_closed();
println!("Client {:?} closed", client); println!("Client {client:?} closed");
} }
} }
} }
@ -346,7 +346,7 @@ mod mount_points {
// Implementation of gst_rtsp_server::RTSPClient virtual methods // Implementation of gst_rtsp_server::RTSPClient virtual methods
impl RTSPMountPointsImpl for MountPoints { impl RTSPMountPointsImpl for MountPoints {
fn make_path(&self, url: &gst_rtsp::RTSPUrl) -> Option<glib::GString> { fn make_path(&self, url: &gst_rtsp::RTSPUrl) -> Option<glib::GString> {
println!("Make path called for {:?} ", url); println!("Make path called for {url:?} ");
self.parent_make_path(url) self.parent_make_path(url)
} }
} }
@ -372,6 +372,6 @@ fn example_main() -> Result<(), Error> {
fn main() { fn main() {
match examples_common::run(example_main) { match examples_common::run(example_main) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -17,7 +17,7 @@ mod examples_common;
struct NoMountPoints; struct NoMountPoints;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Usage: {} LAUNCH_LINE", _0)] #[display(fmt = "Usage: {_0} LAUNCH_LINE")]
struct UsageError(#[error(not(source))] String); struct UsageError(#[error(not(source))] String);
fn main_loop() -> Result<(), Error> { fn main_loop() -> Result<(), Error> {
@ -89,6 +89,6 @@ fn example_main() -> Result<(), Error> {
fn main() { fn main() {
match examples_common::run(example_main) { match examples_common::run(example_main) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -229,7 +229,7 @@ mod fir_filter {
} }
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")]
struct ErrorMessage { struct ErrorMessage {
src: glib::GString, src: glib::GString,
error: glib::Error, error: glib::Error,
@ -321,7 +321,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
fn example_main() { fn example_main() {
match create_pipeline().and_then(main_loop) { match create_pipeline().and_then(main_loop) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -26,11 +26,11 @@ use gst::prelude::*;
mod examples_common; mod examples_common;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Missing element {}", _0)] #[display(fmt = "Missing element {_0}")]
struct MissingElement(#[error(not(source))] String); struct MissingElement(#[error(not(source))] String);
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")]
struct ErrorMessage { struct ErrorMessage {
src: glib::GString, src: glib::GString,
error: glib::Error, error: glib::Error,
@ -112,6 +112,6 @@ fn main() {
// (but not necessary in normal Cocoa applications where this is set up automatically) // (but not necessary in normal Cocoa applications where this is set up automatically)
match examples_common::run(example_main) { match examples_common::run(example_main) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -15,7 +15,7 @@ use gst::{element_error, prelude::*};
mod examples_common; mod examples_common;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")]
struct ErrorMessage { struct ErrorMessage {
src: glib::GString, src: glib::GString,
error: glib::Error, error: glib::Error,
@ -27,8 +27,7 @@ fn create_pipeline(uri: String, out_path: std::path::PathBuf) -> Result<gst::Pip
// Create our pipeline from a pipeline description string. // Create our pipeline from a pipeline description string.
let pipeline = gst::parse_launch(&format!( let pipeline = gst::parse_launch(&format!(
"uridecodebin uri={} ! videoconvert ! appsink name=sink", "uridecodebin uri={uri} ! videoconvert ! appsink name=sink"
uri
))? ))?
.downcast::<gst::Pipeline>() .downcast::<gst::Pipeline>()
.expect("Expected a gst::Pipeline"); .expect("Expected a gst::Pipeline");
@ -174,7 +173,7 @@ fn main_loop(pipeline: gst::Pipeline, position: u64) -> Result<(), Error> {
MessageView::AsyncDone(..) => { MessageView::AsyncDone(..) => {
if !seeked { if !seeked {
// AsyncDone means that the pipeline has started now and that we can seek // AsyncDone means that the pipeline has started now and that we can seek
println!("Got AsyncDone message, seeking to {}s", position); println!("Got AsyncDone message, seeking to {position}s");
if pipeline if pipeline
.seek_simple(gst::SeekFlags::FLUSH, position * gst::ClockTime::SECOND) .seek_simple(gst::SeekFlags::FLUSH, position * gst::ClockTime::SECOND)
@ -240,7 +239,7 @@ fn example_main() {
match create_pipeline(uri, out_path).and_then(|pipeline| main_loop(pipeline, position)) { match create_pipeline(uri, out_path).and_then(|pipeline| main_loop(pipeline, position)) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -109,7 +109,7 @@ fn example_main() {
println!("\nReceived toc: {:?} - updated: {}", toc.scope(), updated); println!("\nReceived toc: {:?} - updated: {}", toc.scope(), updated);
// Get a list of tags that are ToC specific. // Get a list of tags that are ToC specific.
if let Some(tags) = toc.tags() { if let Some(tags) = toc.tags() {
println!("- tags: {}", tags); println!("- tags: {tags}");
} }
// ToCs do not have a fixed structure. Depending on the format that // ToCs do not have a fixed structure. Depending on the format that
// they were parsed from, they might have different tree-like structures, // they were parsed from, they might have different tree-like structures,
@ -124,11 +124,11 @@ fn example_main() {
println!("\t{:?} - {}", toc_entry.entry_type(), toc_entry.uid()); println!("\t{:?} - {}", toc_entry.entry_type(), toc_entry.uid());
// Every ToC entry can have a set of timestamps (start, stop). // Every ToC entry can have a set of timestamps (start, stop).
if let Some((start, stop)) = toc_entry.start_stop_times() { if let Some((start, stop)) = toc_entry.start_stop_times() {
println!("\t- start: {}, stop: {}", start, stop); println!("\t- start: {start}, stop: {stop}");
} }
// Every ToC entry can have tags to it. // Every ToC entry can have tags to it.
if let Some(tags) = toc_entry.tags() { if let Some(tags) = toc_entry.tags() {
println!("\t- tags: {}", tags); println!("\t- tags: {tags}");
} }
// Every ToC entry can have a set of child entries. // Every ToC entry can have a set of child entries.
// With this structure, you can create trees of arbitrary depth. // With this structure, you can create trees of arbitrary depth.
@ -139,10 +139,10 @@ fn example_main() {
toc_sub_entry.uid() toc_sub_entry.uid()
); );
if let Some((start, stop)) = toc_sub_entry.start_stop_times() { if let Some((start, stop)) = toc_sub_entry.start_stop_times() {
println!("\t\t- start: {}, stop: {}", start, stop); println!("\t\t- start: {start}, stop: {stop}");
} }
if let Some(tags) = toc_sub_entry.tags() { if let Some(tags) = toc_sub_entry.tags() {
println!("\t\t- tags: {}", tags); println!("\t\t- tags: {tags}");
} }
} }
} }

View file

@ -27,7 +27,7 @@ use gst::{element_error, prelude::*};
mod examples_common; mod examples_common;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")]
struct ErrorMessage { struct ErrorMessage {
src: glib::GString, src: glib::GString,
error: glib::Error, error: glib::Error,
@ -212,6 +212,6 @@ fn main() {
// (but not necessary in normal Cocoa applications where this is set up automatically) // (but not necessary in normal Cocoa applications where this is set up automatically)
match examples_common::run(example_main) { match examples_common::run(example_main) {
Ok(r) => r, Ok(r) => r,
Err(e) => eprintln!("Error! {}", e), Err(e) => eprintln!("Error! {e}"),
} }
} }

View file

@ -12,7 +12,7 @@ use gst::element_error;
use gst_gl::prelude::*; use gst_gl::prelude::*;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")]
struct ErrorMessage { struct ErrorMessage {
src: glib::GString, src: glib::GString,
error: glib::Error, error: glib::Error,
@ -189,7 +189,7 @@ fn load(gl_context: &glutin::WindowedContext<glutin::PossiblyCurrent>) -> Gl {
String::from_utf8(data).unwrap() String::from_utf8(data).unwrap()
}; };
println!("OpenGL version {}", version); println!("OpenGL version {version}");
let (program, attr_position, attr_texture, vao, vertex_buffer, vbo_indices) = unsafe { let (program, attr_position, attr_texture, vao, vertex_buffer, vbo_indices) = unsafe {
let vs = gl.CreateShader(gl::VERTEX_SHADER); let vs = gl.CreateShader(gl::VERTEX_SHADER);
@ -390,7 +390,7 @@ impl App {
) )
} }
#[allow(unreachable_patterns)] #[allow(unreachable_patterns)]
handler => panic!("Unsupported platform: {:?}.", handler), handler => panic!("Unsupported platform: {handler:?}."),
}; };
shared_context = shared_context =
@ -438,7 +438,7 @@ impl App {
} }
if let Err(e) = event_proxy.lock().unwrap().send_event(Message::BusEvent) { if let Err(e) = event_proxy.lock().unwrap().send_event(Message::BusEvent) {
eprintln!("Failed to send BusEvent to event proxy: {}", e) eprintln!("Failed to send BusEvent to event proxy: {e}")
} }
gst::BusSyncReply::Pass gst::BusSyncReply::Pass

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -108,12 +108,12 @@ impl AudioFormatInfo {
let unpack_width = unpack_format.width() as usize; let unpack_width = unpack_format.width() as usize;
if unpack_width == 0 || self.0.unpack_func.is_none() { if unpack_width == 0 || self.0.unpack_func.is_none() {
panic!("No unpack format for {:?}", self); panic!("No unpack format for {self:?}");
} }
let self_width = self.width() as usize; let self_width = self.width() as usize;
if self_width == 0 { if self_width == 0 {
panic!("No width for {:?}", self); panic!("No width for {self:?}");
} }
if src.len() % (self_width / 8) != 0 { if src.len() % (self_width / 8) != 0 {
@ -142,12 +142,12 @@ impl AudioFormatInfo {
let unpack_width = unpack_format.width() as usize; let unpack_width = unpack_format.width() as usize;
if unpack_width == 0 || self.0.pack_func.is_none() { if unpack_width == 0 || self.0.pack_func.is_none() {
panic!("No unpack format for {:?}", self); panic!("No unpack format for {self:?}");
} }
let self_width = self.width() as usize; let self_width = self.width() as usize;
if self_width == 0 { if self_width == 0 {
panic!("No width for {:?}", self); panic!("No width for {self:?}");
} }
if src.len() % (unpack_width / 8) != 0 { if src.len() % (unpack_width / 8) != 0 {

View file

@ -141,7 +141,7 @@ impl<T> AudioCapsBuilder<T> {
gst::Bitmask::new(crate::AudioChannelPosition::fallback_mask(channels as u32)), gst::Bitmask::new(crate::AudioChannelPosition::fallback_mask(channels as u32)),
), ),
}, },
Err(e) => panic!("{:?}", e), Err(e) => panic!("{e:?}"),
} }
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -11,9 +11,9 @@ pub trait VideoFrameGLExt {
info: &gst_video::VideoInfo, info: &gst_video::VideoInfo,
) -> Result<gst_video::VideoFrame<Readable>, gst::Buffer>; ) -> Result<gst_video::VideoFrame<Readable>, gst::Buffer>;
fn from_buffer_ref_readable_gl<'a, 'b>( fn from_buffer_ref_readable_gl<'a>(
buffer: &'a gst::BufferRef, buffer: &'a gst::BufferRef,
info: &'b gst_video::VideoInfo, info: &gst_video::VideoInfo,
) -> Result<gst_video::VideoFrameRef<&'a gst::BufferRef>, glib::error::BoolError>; ) -> Result<gst_video::VideoFrameRef<&'a gst::BufferRef>, glib::error::BoolError>;
#[doc(alias = "get_texture_id")] #[doc(alias = "get_texture_id")]
@ -29,9 +29,9 @@ impl VideoFrameGLExt for gst_video::VideoFrame<Readable> {
gst_video::VideoFrameRef::<&gst::BufferRef>::from_buffer_readable_gl(buffer, info) gst_video::VideoFrameRef::<&gst::BufferRef>::from_buffer_readable_gl(buffer, info)
} }
fn from_buffer_ref_readable_gl<'a, 'b>( fn from_buffer_ref_readable_gl<'a>(
buffer: &'a gst::BufferRef, buffer: &'a gst::BufferRef,
info: &'b gst_video::VideoInfo, info: &gst_video::VideoInfo,
) -> Result<gst_video::VideoFrameRef<&'a gst::BufferRef>, glib::error::BoolError> { ) -> Result<gst_video::VideoFrameRef<&'a gst::BufferRef>, glib::error::BoolError> {
skip_assert_initialized!(); skip_assert_initialized!();
gst_video::VideoFrameRef::<&gst::BufferRef>::from_buffer_ref_readable_gl(buffer, info) gst_video::VideoFrameRef::<&gst::BufferRef>::from_buffer_ref_readable_gl(buffer, info)
@ -87,9 +87,9 @@ impl<'a> VideoFrameGLExt for gst_video::VideoFrameRef<&'a gst::BufferRef> {
} }
} }
fn from_buffer_ref_readable_gl<'b, 'c>( fn from_buffer_ref_readable_gl<'b>(
buffer: &'b gst::BufferRef, buffer: &'b gst::BufferRef,
info: &'c gst_video::VideoInfo, info: &gst_video::VideoInfo,
) -> Result<gst_video::VideoFrameRef<&'b gst::BufferRef>, glib::error::BoolError> { ) -> Result<gst_video::VideoFrameRef<&'b gst::BufferRef>, glib::error::BoolError> {
skip_assert_initialized!(); skip_assert_initialized!();

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -782,6 +782,6 @@ mod tests {
init(); init();
let sdp = SDPMedia::new(); let sdp = SDPMedia::new();
assert!(!format!("{:?}", sdp).is_empty()); assert!(!format!("{sdp:?}").is_empty());
} }
} }

View file

@ -1284,6 +1284,6 @@ mod tests {
init(); init();
let sdp = SDPMessage::new(); let sdp = SDPMessage::new();
assert!(!format!("{:?}", sdp).is_empty()); assert!(!format!("{sdp:?}").is_empty());
} }
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -583,7 +583,7 @@ mod tests {
impl Consumer { impl Consumer {
fn new(id: &str) -> Self { fn new(id: &str) -> Self {
let pipeline = gst::parse_launch(&format!("appsrc name={} ! appsink name=sink", id)) let pipeline = gst::parse_launch(&format!("appsrc name={id} ! appsink name=sink"))
.unwrap() .unwrap()
.downcast::<gst::Pipeline>() .downcast::<gst::Pipeline>()
.unwrap(); .unwrap();
@ -676,7 +676,7 @@ mod tests {
assert!(producer.last_sample().is_none()); assert!(producer.last_sample().is_none());
for i in 0..10 { for i in 0..10 {
let caps = gst::Caps::from_str(&format!("test,n={}", i)).unwrap(); let caps = gst::Caps::from_str(&format!("test,n={i}")).unwrap();
producer_src.set_caps(Some(&caps)); producer_src.set_caps(Some(&caps));
producer_src.push_buffer(gst::Buffer::new()).unwrap(); producer_src.push_buffer(gst::Buffer::new()).unwrap();

View file

@ -194,7 +194,7 @@ impl VideoFormatInfo {
let unpack_format = Self::from_format(self.unpack_format()); let unpack_format = Self::from_format(self.unpack_format());
if unpack_format.pixel_stride()[0] == 0 || self.0.unpack_func.is_none() { if unpack_format.pixel_stride()[0] == 0 || self.0.unpack_func.is_none() {
panic!("No unpack format for {:?}", self); panic!("No unpack format for {self:?}");
} }
if src.len() != self.n_planes() as usize { if src.len() != self.n_planes() as usize {
@ -222,7 +222,7 @@ impl VideoFormatInfo {
< self.scale_width(plane as u8, width as u32) as i32 < self.scale_width(plane as u8, width as u32) as i32
* self.pixel_stride()[plane as usize] * self.pixel_stride()[plane as usize]
{ {
panic!("Too small source stride for plane {}", plane); panic!("Too small source stride for plane {plane}");
} }
let plane_size = y * stride[plane as usize] let plane_size = y * stride[plane as usize]
@ -230,7 +230,7 @@ impl VideoFormatInfo {
* self.pixel_stride()[plane as usize]; * self.pixel_stride()[plane as usize];
if src[plane as usize].len() < plane_size as usize { if src[plane as usize].len() < plane_size as usize {
panic!("Too small source plane size for plane {}", plane); panic!("Too small source plane size for plane {plane}");
} }
} }
@ -270,7 +270,7 @@ impl VideoFormatInfo {
let unpack_format = Self::from_format(self.unpack_format()); let unpack_format = Self::from_format(self.unpack_format());
if unpack_format.pixel_stride()[0] == 0 || self.0.unpack_func.is_none() { if unpack_format.pixel_stride()[0] == 0 || self.0.unpack_func.is_none() {
panic!("No unpack format for {:?}", self); panic!("No unpack format for {self:?}");
} }
if dest.len() != self.n_planes() as usize { if dest.len() != self.n_planes() as usize {
@ -298,7 +298,7 @@ impl VideoFormatInfo {
< self.scale_width(plane as u8, width as u32) as i32 < self.scale_width(plane as u8, width as u32) as i32
* self.pixel_stride()[plane as usize] * self.pixel_stride()[plane as usize]
{ {
panic!("Too small destination stride for plane {}", plane); panic!("Too small destination stride for plane {plane}");
} }
let plane_size = y * dest_stride[plane as usize] let plane_size = y * dest_stride[plane as usize]
@ -306,7 +306,7 @@ impl VideoFormatInfo {
* self.pixel_stride()[plane as usize]; * self.pixel_stride()[plane as usize];
if dest[plane as usize].len() < plane_size as usize { if dest[plane as usize].len() < plane_size as usize {
panic!("Too small destination plane size for plane {}", plane); panic!("Too small destination plane size for plane {plane}");
} }
} }

View file

@ -383,7 +383,7 @@ impl VideoRegionOfInterestMeta {
#[doc(alias = "get_param")] #[doc(alias = "get_param")]
#[inline] #[inline]
pub fn param<'b>(&self, name: &'b str) -> Option<&gst::StructureRef> { pub fn param<'b>(&'b self, name: &str) -> Option<&'b gst::StructureRef> {
self.params().find(|s| s.name() == name) self.params().find(|s| s.name() == name)
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -1243,7 +1243,7 @@ mod tests {
crate::init().unwrap(); crate::init().unwrap();
let caps = Caps::builder("foo/bar").build(); let caps = Caps::builder("foo/bar").build();
format!("{}", caps); format!("{caps}");
} }
#[test] #[test]
@ -1344,15 +1344,15 @@ mod tests {
crate::init().unwrap(); crate::init().unwrap();
let caps = Caps::new_any(); let caps = Caps::new_any();
assert_eq!(format!("{:?}", caps), "Caps(\"ANY\")"); assert_eq!(format!("{caps:?}"), "Caps(\"ANY\")");
let caps = Caps::new_empty(); let caps = Caps::new_empty();
assert_eq!(format!("{:?}", caps), "Caps(\"EMPTY\")"); assert_eq!(format!("{caps:?}"), "Caps(\"EMPTY\")");
let caps = Caps::builder_full_with_any_features() let caps = Caps::builder_full_with_any_features()
.structure(Structure::builder("audio/x-raw").build()) .structure(Structure::builder("audio/x-raw").build())
.build(); .build();
assert_eq!(format!("{:?}", caps), "Caps(audio/x-raw(ANY))"); assert_eq!(format!("{caps:?}"), "Caps(audio/x-raw(ANY))");
let caps = Caps::builder_full_with_features(CapsFeatures::new(["foo:bla"])) let caps = Caps::builder_full_with_features(CapsFeatures::new(["foo:bla"]))
.structure( .structure(
@ -1370,7 +1370,7 @@ mod tests {
) )
.build(); .build();
assert_eq!(format!("{:?}", caps), "Caps(audio/x-raw(foo:bla) { struct: Structure(nested { badger: (gboolean) TRUE }) }, video/x-raw(foo:bla) { width: (guint) 800 })"); assert_eq!(format!("{caps:?}"), "Caps(audio/x-raw(foo:bla) { struct: Structure(nested { badger: (gboolean) TRUE }) }, video/x-raw(foo:bla) { width: (guint) 800 })");
let caps = Caps::builder_full() let caps = Caps::builder_full()
.structure( .structure(
@ -1381,6 +1381,6 @@ mod tests {
) )
.build(); .build();
assert_eq!(format!("{:?}", caps), "Caps(video/x-raw(memory:SystemMemory) { array: Array([(gchararray) \"a\", (gchararray) \"b\", (gchararray) \"c\"]), list: List([(gchararray) \"d\", (gchararray) \"e\", (gchararray) \"f\"]) })"); assert_eq!(format!("{caps:?}"), "Caps(video/x-raw(memory:SystemMemory) { array: Array([(gchararray) \"a\", (gchararray) \"b\", (gchararray) \"c\"]), list: List([(gchararray) \"d\", (gchararray) \"e\", (gchararray) \"f\"]) })");
} }
} }

View file

@ -111,8 +111,7 @@ impl Serialize for DateTime {
DateTimeVariants::Y(self.year()) DateTimeVariants::Y(self.year())
} else { } else {
return Err(ser::Error::custom(format!( return Err(ser::Error::custom(format!(
"no parts could be found in `DateTime` {}", "no parts could be found in `DateTime` {self}",
self,
))); )));
}; };

View file

@ -192,7 +192,7 @@ mod tests {
7, 7,
); );
assert_eq!( assert_eq!(
format!("{}", e), format!("{e}"),
"Error Some(\"message\") (Some(\"debug\")) at filename:7" "Error Some(\"message\") (Some(\"debug\")) at filename:7"
); );
} }
@ -202,9 +202,6 @@ mod tests {
crate::init().unwrap(); crate::init().unwrap();
let e: LoggableError = glib::BoolError::new("msg", "filename", "function", 7).into(); let e: LoggableError = glib::BoolError::new("msg", "filename", "function", 7).into();
assert_eq!( assert_eq!(format!("{e}"), "Error \"GST_RUST\": \"msg\" at filename:7");
format!("{}", e),
"Error \"GST_RUST\": \"msg\" at filename:7"
);
} }
} }

View file

@ -518,17 +518,17 @@ fn write_clocktime<W: io::Write>(
let (h, m) = num_integer::div_rem(m, 60); let (h, m) = num_integer::div_rem(m, 60);
// Write HH:MM:SS // Write HH:MM:SS
write!(writer, "{}:{:02}:{:02}", h, m, s)?; write!(writer, "{h}:{m:02}:{s:02}")?;
if precision > 0 { if precision > 0 {
// Format the nanoseconds into a stack-allocated string // Format the nanoseconds into a stack-allocated string
// The value is zero-padded so always 9 digits long // The value is zero-padded so always 9 digits long
let mut buf = [0u8; 9]; let mut buf = [0u8; 9];
write!(&mut buf[..], "{:09}", ns).unwrap(); write!(&mut buf[..], "{ns:09}").unwrap();
let buf_str = std::str::from_utf8(&buf[..]).unwrap(); let buf_str = std::str::from_utf8(&buf[..]).unwrap();
// Write decimal point and a prefix of the nanoseconds for more precision // Write decimal point and a prefix of the nanoseconds for more precision
write!(writer, ".{:.p$}", buf_str, p = precision)?; write!(writer, ".{buf_str:.precision$}")?;
} }
} else { } else {
// Undefined time // Undefined time
@ -1152,9 +1152,9 @@ mod tests {
"12:43:54.908569837" "12:43:54.908569837"
); );
assert_eq!(format!("{:.0}", lots), "5124095:34:33"); assert_eq!(format!("{lots:.0}"), "5124095:34:33");
assert_eq!(format!("{:.3}", lots), "5124095:34:33.709"); assert_eq!(format!("{lots:.3}"), "5124095:34:33.709");
assert_eq!(format!("{}", lots), "5124095:34:33.709551614"); assert_eq!(format!("{lots}"), "5124095:34:33.709551614");
// Precision caps at 9 // Precision caps at 9
assert_eq!( assert_eq!(
@ -1165,7 +1165,7 @@ mod tests {
format!("{:.10}", DisplayableOptClockTime(some)), format!("{:.10}", DisplayableOptClockTime(some)),
"12:43:54.908569837" "12:43:54.908569837"
); );
assert_eq!(format!("{:.10}", lots), "5124095:34:33.709551614"); assert_eq!(format!("{lots:.10}"), "5124095:34:33.709551614");
// Short width // Short width
@ -1189,9 +1189,9 @@ mod tests {
"12:43:54.908569837" "12:43:54.908569837"
); );
assert_eq!(format!("{:4.0}", lots), "5124095:34:33"); assert_eq!(format!("{lots:4.0}"), "5124095:34:33");
assert_eq!(format!("{:4.3}", lots), "5124095:34:33.709"); assert_eq!(format!("{lots:4.3}"), "5124095:34:33.709");
assert_eq!(format!("{:4}", lots), "5124095:34:33.709551614"); assert_eq!(format!("{lots:4}"), "5124095:34:33.709551614");
// Simple padding // Simple padding
@ -1269,15 +1269,15 @@ mod tests {
" 12:43:54.908569837 " " 12:43:54.908569837 "
); );
assert_eq!(format!("{:>14.0}", lots), " 5124095:34:33"); assert_eq!(format!("{lots:>14.0}"), " 5124095:34:33");
assert_eq!(format!("{:<14.0}", lots), "5124095:34:33 "); assert_eq!(format!("{lots:<14.0}"), "5124095:34:33 ");
assert_eq!(format!("{:^15.0}", lots), " 5124095:34:33 "); assert_eq!(format!("{lots:^15.0}"), " 5124095:34:33 ");
assert_eq!(format!("{:>18.3}", lots), " 5124095:34:33.709"); assert_eq!(format!("{lots:>18.3}"), " 5124095:34:33.709");
assert_eq!(format!("{:<18.3}", lots), "5124095:34:33.709 "); assert_eq!(format!("{lots:<18.3}"), "5124095:34:33.709 ");
assert_eq!(format!("{:^19.3}", lots), " 5124095:34:33.709 "); assert_eq!(format!("{lots:^19.3}"), " 5124095:34:33.709 ");
assert_eq!(format!("{:>24}", lots), " 5124095:34:33.709551614"); assert_eq!(format!("{lots:>24}"), " 5124095:34:33.709551614");
assert_eq!(format!("{:<24}", lots), "5124095:34:33.709551614 "); assert_eq!(format!("{lots:<24}"), "5124095:34:33.709551614 ");
assert_eq!(format!("{:^25}", lots), " 5124095:34:33.709551614 "); assert_eq!(format!("{lots:^25}"), " 5124095:34:33.709551614 ");
// Padding with sign or zero-extension // Padding with sign or zero-extension
@ -1355,15 +1355,15 @@ mod tests {
"+0012:43:54.908569837" "+0012:43:54.908569837"
); );
assert_eq!(format!("{:+16.0}", lots), " +5124095:34:33"); assert_eq!(format!("{lots:+16.0}"), " +5124095:34:33");
assert_eq!(format!("{:016.0}", lots), "0005124095:34:33"); assert_eq!(format!("{lots:016.0}"), "0005124095:34:33");
assert_eq!(format!("{:+016.0}", lots), "+005124095:34:33"); assert_eq!(format!("{lots:+016.0}"), "+005124095:34:33");
assert_eq!(format!("{:+20.3}", lots), " +5124095:34:33.709"); assert_eq!(format!("{lots:+20.3}"), " +5124095:34:33.709");
assert_eq!(format!("{:020.3}", lots), "0005124095:34:33.709"); assert_eq!(format!("{lots:020.3}"), "0005124095:34:33.709");
assert_eq!(format!("{:+020.3}", lots), "+005124095:34:33.709"); assert_eq!(format!("{lots:+020.3}"), "+005124095:34:33.709");
assert_eq!(format!("{:+26}", lots), " +5124095:34:33.709551614"); assert_eq!(format!("{lots:+26}"), " +5124095:34:33.709551614");
assert_eq!(format!("{:026}", lots), "0005124095:34:33.709551614"); assert_eq!(format!("{lots:026}"), "0005124095:34:33.709551614");
assert_eq!(format!("{:+026}", lots), "+005124095:34:33.709551614"); assert_eq!(format!("{lots:+026}"), "+005124095:34:33.709551614");
} }
#[test] #[test]

View file

@ -619,7 +619,7 @@ impl fmt::Display for Format {
Self::Time => f.write_str("time"), Self::Time => f.write_str("time"),
Self::Buffers => f.write_str("buffers"), Self::Buffers => f.write_str("buffers"),
Self::Percent => f.write_str("%"), Self::Percent => f.write_str("%"),
Self::__Unknown(format) => write!(f, "(format: {})", format), Self::__Unknown(format) => write!(f, "(format: {format})"),
} }
} }
} }

View file

@ -1121,7 +1121,7 @@ impl fmt::Display for LoggedObject {
} }
}; };
write!(f, "{}:{}", parent_name, name) write!(f, "{parent_name}:{name}")
} else if glib::gobject_ffi::g_type_is_a(type_, ffi::gst_object_get_type()) } else if glib::gobject_ffi::g_type_is_a(type_, ffi::gst_object_get_type())
!= glib::ffi::GFALSE != glib::ffi::GFALSE
{ {
@ -1133,7 +1133,7 @@ impl fmt::Display for LoggedObject {
.to_str() .to_str()
.unwrap_or("<invalid name>") .unwrap_or("<invalid name>")
}; };
write!(f, "{}", name) write!(f, "{name}")
} else { } else {
let type_name = CStr::from_ptr(glib::gobject_ffi::g_type_name(type_)); let type_name = CStr::from_ptr(glib::gobject_ffi::g_type_name(type_));
write!( write!(
@ -1144,7 +1144,7 @@ impl fmt::Display for LoggedObject {
) )
} }
} else { } else {
write!(f, "{:?}", ptr) write!(f, "{ptr:?}")
} }
} }
} }

View file

@ -39,7 +39,7 @@ impl<O: IsA<crate::Object>> GstObjectExtManual for O {
f: F, f: F,
) -> SignalHandlerId { ) -> SignalHandlerId {
let signal_name = if let Some(name) = name { let signal_name = if let Some(name) = name {
format!("deep-notify::{}", name) format!("deep-notify::{name}")
} else { } else {
"deep-notify".into() "deep-notify".into()
}; };
@ -54,14 +54,12 @@ impl<O: IsA<crate::Object>> GstObjectExtManual for O {
let obj: O = unsafe { let obj: O = unsafe {
values[0] values[0]
.get::<crate::Object>() .get::<crate::Object>()
.unwrap_or_else(|err| { .unwrap_or_else(|err| panic!("Object signal \"deep-notify\": values[0]: {err}"))
panic!("Object signal \"deep-notify\": values[0]: {}", err)
})
.unsafe_cast() .unsafe_cast()
}; };
let prop_obj: crate::Object = values[1] let prop_obj: crate::Object = values[1]
.get() .get()
.unwrap_or_else(|err| panic!("Object signal \"deep-notify\": values[1]: {}", err)); .unwrap_or_else(|err| panic!("Object signal \"deep-notify\": values[1]: {err}"));
let pspec = unsafe { let pspec = unsafe {
let pspec = glib::gobject_ffi::g_value_get_param(values[2].to_glib_none().0); let pspec = glib::gobject_ffi::g_value_get_param(values[2].to_glib_none().0);

View file

@ -1097,10 +1097,7 @@ unsafe fn update_probe_info(
{ {
// Buffer or Event consumed by probe // Buffer or Event consumed by probe
} }
other => panic!( other => panic!("Bad data for {data_type:?} pad probe returning Handled: {other:?}"),
"Bad data for {:?} pad probe returning Handled: {:?}",
data_type, other
),
} }
} else { } else {
match probe_info.data { match probe_info.data {

View file

@ -169,7 +169,7 @@ impl StreamCollection {
} }
unsafe { unsafe {
let f: Box_<F> = Box_::new(f); let f: Box_<F> = Box_::new(f);
let detailed_signal_name = detail.map(|name| format!("stream-notify::{}\0", name)); let detailed_signal_name = detail.map(|name| format!("stream-notify::{name}\0"));
let signal_name: &[u8] = detailed_signal_name let signal_name: &[u8] = detailed_signal_name
.as_ref() .as_ref()
.map_or(&b"stream-notify\0"[..], |n| n.as_bytes()); .map_or(&b"stream-notify\0"[..], |n| n.as_bytes());

View file

@ -1260,6 +1260,6 @@ mod tests {
.field("f6", crate::List::new(["d", "e", "f"])) .field("f6", crate::List::new(["d", "e", "f"]))
.build(); .build();
assert_eq!(format!("{:?}", s), "Structure(test { f1: (gchararray) \"abc\", f2: (gchararray) \"bcd\", f3: (gint) 123, f4: Structure(nested { badger: (gboolean) TRUE }), f5: Array([(gchararray) \"a\", (gchararray) \"b\", (gchararray) \"c\"]), f6: List([(gchararray) \"d\", (gchararray) \"e\", (gchararray) \"f\"]) })"); assert_eq!(format!("{s:?}"), "Structure(test { f1: (gchararray) \"abc\", f2: (gchararray) \"bcd\", f3: (gint) 123, f4: Structure(nested { badger: (gboolean) TRUE }), f5: Array([(gchararray) \"a\", (gchararray) \"b\", (gchararray) \"c\"]), f6: List([(gchararray) \"d\", (gchararray) \"e\", (gchararray) \"f\"]) })");
} }
} }

View file

@ -18,7 +18,7 @@ pub fn post_panic_error_message(
}); });
let msg = if let Some(cause) = cause { let msg = if let Some(cause) = cause {
crate::message::Error::builder(crate::LibraryError::Failed, &format!("Panicked: {}", cause)) crate::message::Error::builder(crate::LibraryError::Failed, &format!("Panicked: {cause}"))
.src(src) .src(src)
.build() .build()
} else { } else {

View file

@ -1356,14 +1356,14 @@ mod tests {
crate::init().unwrap(); crate::init().unwrap();
let mut tags = TagList::new(); let mut tags = TagList::new();
assert_eq!(format!("{:?}", tags), "TagList"); assert_eq!(format!("{tags:?}"), "TagList");
{ {
let tags = tags.get_mut().unwrap(); let tags = tags.get_mut().unwrap();
tags.add::<Title>(&"some title", TagMergeMode::Append); tags.add::<Title>(&"some title", TagMergeMode::Append);
tags.add::<Duration>(&(ClockTime::SECOND * 120), TagMergeMode::Append); tags.add::<Duration>(&(ClockTime::SECOND * 120), TagMergeMode::Append);
} }
assert_eq!( assert_eq!(
format!("{:?}", tags), format!("{tags:?}"),
"TagList { title: (gchararray) \"some title\", duration: (guint64) 120000000000 }" "TagList { title: (gchararray) \"some title\", duration: (guint64) 120000000000 }"
); );
} }

View file

@ -82,8 +82,7 @@ impl<'a> Serialize for TagValuesSer<'a> {
ser_opt_tag!(value, seq, Sample) ser_opt_tag!(value, seq, Sample)
} else { } else {
Err(ser::Error::custom(format!( Err(ser::Error::custom(format!(
"unimplemented `Tag` serialization for type {}", "unimplemented `Tag` serialization for type {type_id}",
type_id,
))) )))
} }
} }
@ -240,7 +239,7 @@ impl<'de, 'a> Visitor<'de> for TagValuesTupleVisitor<'a> {
fn visit_seq<A: SeqAccess<'de>>(self, mut seq: A) -> Result<(), A::Error> { fn visit_seq<A: SeqAccess<'de>>(self, mut seq: A) -> Result<(), A::Error> {
let name = seq let name = seq
.next_element::<String>() .next_element::<String>()
.map_err(|err| de::Error::custom(format!("Error reading Tag name. {:?}", err)))? .map_err(|err| de::Error::custom(format!("Error reading Tag name. {err:?}")))?
.ok_or_else(|| de::Error::custom("Expected a name for the `Tag` name"))?; .ok_or_else(|| de::Error::custom("Expected a name for the `Tag` name"))?;
seq.next_element_seed(TagValues(name.as_str(), self.0))? seq.next_element_seed(TagValues(name.as_str(), self.0))?
.ok_or_else(|| de::Error::custom("Expected a seq of values for the `Tag`")) .ok_or_else(|| de::Error::custom("Expected a seq of values for the `Tag`"))

View file

@ -3,6 +3,6 @@
#[test] #[test]
fn check_gir_file() { fn check_gir_file() {
let res = gir_format_check::check_gir_file("Gir.toml"); let res = gir_format_check::check_gir_file("Gir.toml");
println!("{}", res); println!("{res}");
assert_eq!(res.nb_errors, 0); assert_eq!(res.nb_errors, 0);
} }

View file

@ -10,7 +10,7 @@ fn tutorial_main() {
// Build the pipeline // Build the pipeline
let uri = let uri =
"https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"; "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
let pipeline = gst::parse_launch(&format!("playbin uri={}", uri)).unwrap(); let pipeline = gst::parse_launch(&format!("playbin uri={uri}")).unwrap();
// Start playing // Start playing
pipeline pipeline

View file

@ -13,7 +13,7 @@ fn tutorial_main() -> Result<(), Error> {
// Build the pipeline // Build the pipeline
let uri = let uri =
"https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"; "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
let pipeline = gst::parse_launch(&format!("playbin uri={}", uri))?; let pipeline = gst::parse_launch(&format!("playbin uri={uri}"))?;
// Start playing // Start playing
let res = pipeline.set_state(gst::State::Playing)?; let res = pipeline.set_state(gst::State::Playing)?;
@ -52,10 +52,10 @@ fn tutorial_main() -> Result<(), Error> {
} }
let percent = buffering.percent(); let percent = buffering.percent();
print!("Buffering ({}%)\r", percent); print!("Buffering ({percent}%)\r");
match std::io::stdout().flush() { match std::io::stdout().flush() {
Ok(_) => {} Ok(_) => {}
Err(err) => eprintln!("Failed: {}", err), Err(err) => eprintln!("Failed: {err}"),
}; };
// Wait until buffering is complete before start/resume playing // Wait until buffering is complete before start/resume playing
@ -87,6 +87,6 @@ fn tutorial_main() -> Result<(), Error> {
fn main() { fn main() {
match tutorials_common::run(tutorial_main) { match tutorials_common::run(tutorial_main) {
Ok(_) => {} Ok(_) => {}
Err(err) => eprintln!("Failed: {}", err), Err(err) => eprintln!("Failed: {err}"),
} }
} }

View file

@ -55,7 +55,7 @@ fn send_seek_event(pipeline: &Element, rate: f64) -> bool {
// If we have not done so, obtain the sink through which we will send the seek events // If we have not done so, obtain the sink through which we will send the seek events
if let Some(video_sink) = pipeline.property::<Option<Element>>("video-sink") { if let Some(video_sink) = pipeline.property::<Option<Element>>("video-sink") {
println!("Current rate: {}\r", rate); println!("Current rate: {rate}\r");
// Send the event // Send the event
video_sink.send_event(seek_event) video_sink.send_event(seek_event)
} else { } else {
@ -123,7 +123,7 @@ USAGE: Choose one of the following options, then press enter:
// Build the pipeline. // Build the pipeline.
let uri = let uri =
"https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"; "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
let pipeline = gst::parse_launch(&format!("playbin uri={}", uri))?; let pipeline = gst::parse_launch(&format!("playbin uri={uri}"))?;
// Start playing. // Start playing.
let _ = pipeline.set_state(State::Playing)?; let _ = pipeline.set_state(State::Playing)?;
@ -151,7 +151,7 @@ USAGE: Choose one of the following options, then press enter:
"PLAYING" "PLAYING"
}; };
playing = !playing; playing = !playing;
println!("Setting state to {}\r", status); println!("Setting state to {status}\r");
} }
Command::DataRateUp => { Command::DataRateUp => {
if send_seek_event(&pipeline, rate * 2.) { if send_seek_event(&pipeline, rate * 2.) {
@ -193,6 +193,6 @@ USAGE: Choose one of the following options, then press enter:
fn main() { fn main() {
match tutorials_common::run(tutorial_main) { match tutorials_common::run(tutorial_main) {
Ok(_) => {} Ok(_) => {}
Err(err) => eprintln!("Failed: {}", err), Err(err) => eprintln!("Failed: {err}"),
} }
} }

View file

@ -62,18 +62,15 @@ fn tutorial_main() {
let is_audio = new_pad_type.starts_with("audio/x-raw"); let is_audio = new_pad_type.starts_with("audio/x-raw");
if !is_audio { if !is_audio {
println!( println!("It has type {new_pad_type} which is not raw audio. Ignoring.");
"It has type {} which is not raw audio. Ignoring.",
new_pad_type
);
return; return;
} }
let res = src_pad.link(&sink_pad); let res = src_pad.link(&sink_pad);
if res.is_err() { if res.is_err() {
println!("Type is {} but link failed.", new_pad_type); println!("Type is {new_pad_type} but link failed.");
} else { } else {
println!("Link succeeded (type {}).", new_pad_type); println!("Link succeeded (type {new_pad_type}).");
} }
}); });

View file

@ -134,10 +134,7 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::Message) {
let new_state = state_changed.current(); let new_state = state_changed.current();
let old_state = state_changed.old(); let old_state = state_changed.old();
println!( println!("Pipeline state changed from {old_state:?} to {new_state:?}");
"Pipeline state changed from {:?} to {:?}",
old_state, new_state
);
custom_data.playing = new_state == gst::State::Playing; custom_data.playing = new_state == gst::State::Playing;
if custom_data.playing { if custom_data.playing {
@ -146,7 +143,7 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::Message) {
let (seekable, start, end) = seeking.result(); let (seekable, start, end) = seeking.result();
custom_data.seek_enabled = seekable; custom_data.seek_enabled = seekable;
if seekable { if seekable {
println!("Seeking is ENABLED from {} to {}", start, end) println!("Seeking is ENABLED from {start} to {end}")
} else { } else {
println!("Seeking is DISABLED for this stream.") println!("Seeking is DISABLED for this stream.")
} }

View file

@ -33,15 +33,15 @@ mod tutorial5 {
// Extract tags from streams of @stype and add the info in the UI. // Extract tags from streams of @stype and add the info in the UI.
fn add_streams_info(playbin: &gst::Element, textbuf: &gtk::TextBuffer, stype: &str) { fn add_streams_info(playbin: &gst::Element, textbuf: &gtk::TextBuffer, stype: &str) {
let propname: &str = &format!("n-{}", stype); let propname: &str = &format!("n-{stype}");
let signame: &str = &format!("get-{}-tags", stype); let signame: &str = &format!("get-{stype}-tags");
let x = playbin.property::<i32>(propname); let x = playbin.property::<i32>(propname);
for i in 0..x { for i in 0..x {
let tags = playbin.emit_by_name::<Option<gst::TagList>>(signame, &[&i]); let tags = playbin.emit_by_name::<Option<gst::TagList>>(signame, &[&i]);
if let Some(tags) = tags { if let Some(tags) = tags {
textbuf.insert_at_cursor(&format!("{} stream {}:\n ", stype, i)); textbuf.insert_at_cursor(&format!("{stype} stream {i}:\n "));
if let Some(codec) = tags.get::<gst::tags::VideoCodec>() { if let Some(codec) = tags.get::<gst::tags::VideoCodec>() {
textbuf.insert_at_cursor(&format!(" codec: {} \n", codec.get())); textbuf.insert_at_cursor(&format!(" codec: {} \n", codec.get()));
@ -123,7 +123,7 @@ mod tutorial5 {
) )
.is_err() .is_err()
{ {
eprintln!("Seeking to {} failed", value); eprintln!("Seeking to {value} failed");
} }
}); });
@ -187,7 +187,7 @@ mod tutorial5 {
video_overlay.set_window_handle(xid as usize); video_overlay.set_window_handle(xid as usize);
} }
} else { } else {
println!("Add support for display type '{}'", display_type_name); println!("Add support for display type '{display_type_name}'");
process::exit(-1); process::exit(-1);
} }
} }
@ -285,13 +285,13 @@ mod tutorial5 {
// Initialize GTK // Initialize GTK
if let Err(err) = gtk::init() { if let Err(err) = gtk::init() {
eprintln!("Failed to initialize GTK: {}", err); eprintln!("Failed to initialize GTK: {err}");
return; return;
} }
// Initialize GStreamer // Initialize GStreamer
if let Err(err) = gst::init() { if let Err(err) = gst::init() {
eprintln!("Failed to initialize Gst: {}", err); eprintln!("Failed to initialize Gst: {err}");
return; return;
} }

View file

@ -5,12 +5,12 @@ mod tutorials_common;
fn print_caps(caps: &gst::CapsRef, prefix: &str) { fn print_caps(caps: &gst::CapsRef, prefix: &str) {
if caps.is_any() { if caps.is_any() {
println!("{}ANY", prefix); println!("{prefix}ANY");
return; return;
} }
if caps.is_empty() { if caps.is_empty() {
println!("{}EMPTY", prefix); println!("{prefix}EMPTY");
return; return;
} }
@ -32,7 +32,7 @@ fn print_pad_template_information(factory: &gst::ElementFactory) {
let long_name = factory let long_name = factory
.metadata("long-name") .metadata("long-name")
.expect("Failed to get long-name of element factory."); .expect("Failed to get long-name of element factory.");
println!("Pad Template for {}:", long_name); println!("Pad Template for {long_name}:");
if factory.num_pad_templates() == 0u32 { if factory.num_pad_templates() == 0u32 {
println!(" None"); println!(" None");
@ -69,7 +69,7 @@ fn print_pad_capabilities(element: &gst::Element, pad_name: &str) {
.static_pad(pad_name) .static_pad(pad_name)
.expect("Could not retrieve pad"); .expect("Could not retrieve pad");
println!("Caps for the {} pad:", pad_name); println!("Caps for the {pad_name} pad:");
let caps = pad.current_caps().unwrap_or_else(|| pad.query_caps(None)); let caps = pad.current_caps().unwrap_or_else(|| pad.query_caps(None));
print_caps(&caps, " "); print_caps(&caps, " ");
} }
@ -145,10 +145,7 @@ fn tutorial_main() {
let new_state = state_changed.current(); let new_state = state_changed.current();
let old_state = state_changed.old(); let old_state = state_changed.old();
println!( println!("Pipeline state changed from {old_state:?} to {new_state:?}");
"Pipeline state changed from {:?} to {:?}",
old_state, new_state
);
print_pad_capabilities(&sink, "sink"); print_pad_capabilities(&sink, "sink");
} }
} }

View file

@ -6,7 +6,7 @@ mod tutorials_common;
fn tutorial_main() { fn tutorial_main() {
// Initialize GStreamer // Initialize GStreamer
if let Err(err) = gst::init() { if let Err(err) = gst::init() {
eprintln!("Failed to initialize Gst: {}", err); eprintln!("Failed to initialize Gst: {err}");
return; return;
} }

View file

@ -42,7 +42,7 @@ impl CustomData {
fn main() { fn main() {
// Initialize GStreamer // Initialize GStreamer
if let Err(err) = gst::init() { if let Err(err) = gst::init() {
eprintln!("Failed to initialize Gst: {}", err); eprintln!("Failed to initialize Gst: {err}");
return; return;
} }

View file

@ -57,7 +57,7 @@ fn print_stream_info(info: &DiscovererStreamInfo, depth: usize) {
} }
} }
println!("{}", tags_str); println!("{tags_str}");
} }
}; };
} }
@ -82,11 +82,11 @@ fn on_discovered(
) { ) {
let uri = discoverer_info.uri(); let uri = discoverer_info.uri();
match discoverer_info.result() { match discoverer_info.result() {
DiscovererResult::Ok => println!("Discovered {}", uri), DiscovererResult::Ok => println!("Discovered {uri}"),
DiscovererResult::UriInvalid => println!("Invalid uri {}", uri), DiscovererResult::UriInvalid => println!("Invalid uri {uri}"),
DiscovererResult::Error => { DiscovererResult::Error => {
if let Some(msg) = error { if let Some(msg) = error {
println!("{}", msg); println!("{msg}");
} else { } else {
println!("Unknown error") println!("Unknown error")
} }
@ -95,7 +95,7 @@ fn on_discovered(
DiscovererResult::Busy => println!("Busy"), DiscovererResult::Busy => println!("Busy"),
DiscovererResult::MissingPlugins => { DiscovererResult::MissingPlugins => {
if let Some(s) = discoverer_info.misc() { if let Some(s) = discoverer_info.misc() {
println!("{}", s); println!("{s}");
} }
} }
_ => println!("Unknown result"), _ => println!("Unknown result"),
@ -110,10 +110,10 @@ fn on_discovered(
if let Some(tags) = discoverer_info.tags() { if let Some(tags) = discoverer_info.tags() {
println!("Tags:"); println!("Tags:");
for (tag, values) in tags.iter_generic() { for (tag, values) in tags.iter_generic() {
print!(" {}: ", tag); print!(" {tag}: ");
values.for_each(|v| { values.for_each(|v| {
if let Some(s) = send_value_as_str(v) { if let Some(s) = send_value_as_str(v) {
println!("{}", s) println!("{s}")
} }
}) })
} }
@ -145,7 +145,7 @@ fn run_discoverer() -> Result<(), Error> {
"https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm" "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"
}; };
println!("Discovering {}", uri); println!("Discovering {uri}");
let loop_ = glib::MainLoop::new(None, false); let loop_ = glib::MainLoop::new(None, false);
let timeout = 5 * gst::ClockTime::SECOND; let timeout = 5 * gst::ClockTime::SECOND;
@ -169,7 +169,7 @@ fn run_discoverer() -> Result<(), Error> {
fn tutorial_main() { fn tutorial_main() {
match run_discoverer() { match run_discoverer() {
Ok(_) => {} Ok(_) => {}
Err(err) => eprintln!("Failed to run discovery: {}", err), Err(err) => eprintln!("Failed to run discovery: {err}"),
} }
} }

View file

@ -12,16 +12,13 @@ fn analyze_streams(playbin: &gst::Element) {
let n_video = playbin.property::<i32>("n-video"); let n_video = playbin.property::<i32>("n-video");
let n_audio = playbin.property::<i32>("n-audio"); let n_audio = playbin.property::<i32>("n-audio");
let n_text = playbin.property::<i32>("n-text"); let n_text = playbin.property::<i32>("n-text");
println!( println!("{n_video} video stream(s), {n_audio} audio stream(s), {n_text} text stream(s)");
"{} video stream(s), {} audio stream(s), {} text stream(s)",
n_video, n_audio, n_text
);
for i in 0..n_video { for i in 0..n_video {
let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-video-tags", &[&i]); let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-video-tags", &[&i]);
if let Some(tags) = tags { if let Some(tags) = tags {
println!("video stream {}:", i); println!("video stream {i}:");
if let Some(codec) = tags.get::<gst::tags::VideoCodec>() { if let Some(codec) = tags.get::<gst::tags::VideoCodec>() {
println!(" codec: {}", codec.get()); println!(" codec: {}", codec.get());
} }
@ -32,7 +29,7 @@ fn analyze_streams(playbin: &gst::Element) {
let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-audio-tags", &[&i]); let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-audio-tags", &[&i]);
if let Some(tags) = tags { if let Some(tags) = tags {
println!("audio stream {}:", i); println!("audio stream {i}:");
if let Some(codec) = tags.get::<gst::tags::AudioCodec>() { if let Some(codec) = tags.get::<gst::tags::AudioCodec>() {
println!(" codec: {}", codec.get()); println!(" codec: {}", codec.get());
} }
@ -49,7 +46,7 @@ fn analyze_streams(playbin: &gst::Element) {
let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-text-tags", &[&i]); let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-text-tags", &[&i]);
if let Some(tags) = tags { if let Some(tags) = tags {
println!("subtitle stream {}:", i); println!("subtitle stream {i}:");
if let Some(codec) = tags.get::<gst::tags::LanguageCode>() { if let Some(codec) = tags.get::<gst::tags::LanguageCode>() {
println!(" language: {}", codec.get()); println!(" language: {}", codec.get());
} }
@ -60,8 +57,7 @@ fn analyze_streams(playbin: &gst::Element) {
let current_audio = playbin.property::<i32>("current-audio"); let current_audio = playbin.property::<i32>("current-audio");
let current_text = playbin.property::<i32>("current-text"); let current_text = playbin.property::<i32>("current-text");
println!( println!(
"Currently playing video stream {}, audio stream {}, text stream {}", "Currently playing video stream {current_video}, audio stream {current_audio}, text stream {current_text}"
current_video, current_audio, current_text
); );
println!("Type any number and hit ENTER to select a different audio stream"); println!("Type any number and hit ENTER to select a different audio stream");
} }
@ -79,7 +75,7 @@ fn handle_keyboard(playbin: &gst::Element, main_loop: &glib::MainLoop) {
let n_audio = playbin.property::<i32>("n-audio"); let n_audio = playbin.property::<i32>("n-audio");
if index < n_audio { if index < n_audio {
println!("Setting current audio stream to {}", index); println!("Setting current audio stream to {index}");
playbin.set_property("current-audio", index); playbin.set_property("current-audio", index);
} else { } else {
eprintln!("Index out of bounds"); eprintln!("Index out of bounds");
@ -189,6 +185,6 @@ fn main() {
// (but not necessary in normal Cocoa applications where this is set up automatically) // (but not necessary in normal Cocoa applications where this is set up automatically)
match tutorials_common::run(tutorial_main) { match tutorials_common::run(tutorial_main) {
Ok(_) => {} Ok(_) => {}
Err(err) => eprintln!("Failed: {}", err), Err(err) => eprintln!("Failed: {err}"),
}; };
} }

View file

@ -12,16 +12,13 @@ fn analyze_streams(playbin: &gst::Element) {
let n_video = playbin.property::<i32>("n-video"); let n_video = playbin.property::<i32>("n-video");
let n_audio = playbin.property::<i32>("n-audio"); let n_audio = playbin.property::<i32>("n-audio");
let n_text = playbin.property::<i32>("n-text"); let n_text = playbin.property::<i32>("n-text");
println!( println!("{n_video} video stream(s), {n_audio} audio stream(s), {n_text} subtitle stream(s)");
"{} video stream(s), {} audio stream(s), {} subtitle stream(s)",
n_video, n_audio, n_text
);
for i in 0..n_video { for i in 0..n_video {
let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-video-tags", &[&i]); let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-video-tags", &[&i]);
if let Some(tags) = tags { if let Some(tags) = tags {
println!("video stream {}:", i); println!("video stream {i}:");
if let Some(codec) = tags.get::<gst::tags::VideoCodec>() { if let Some(codec) = tags.get::<gst::tags::VideoCodec>() {
println!(" codec: {}", codec.get()); println!(" codec: {}", codec.get());
} }
@ -32,7 +29,7 @@ fn analyze_streams(playbin: &gst::Element) {
let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-audio-tags", &[&i]); let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-audio-tags", &[&i]);
if let Some(tags) = tags { if let Some(tags) = tags {
println!("audio stream {}:", i); println!("audio stream {i}:");
if let Some(codec) = tags.get::<gst::tags::AudioCodec>() { if let Some(codec) = tags.get::<gst::tags::AudioCodec>() {
println!(" codec: {}", codec.get()); println!(" codec: {}", codec.get());
} }
@ -49,7 +46,7 @@ fn analyze_streams(playbin: &gst::Element) {
let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-text-tags", &[&i]); let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-text-tags", &[&i]);
if let Some(tags) = tags { if let Some(tags) = tags {
println!("subtitle stream {}:", i); println!("subtitle stream {i}:");
if let Some(codec) = tags.get::<gst::tags::LanguageCode>() { if let Some(codec) = tags.get::<gst::tags::LanguageCode>() {
println!(" language: {}", codec.get()); println!(" language: {}", codec.get());
} }
@ -62,8 +59,7 @@ fn analyze_streams(playbin: &gst::Element) {
let current_audio = playbin.property::<i32>("current-audio"); let current_audio = playbin.property::<i32>("current-audio");
let current_text = playbin.property::<i32>("current-text"); let current_text = playbin.property::<i32>("current-text");
println!( println!(
"Currently playing video stream {}, audio stream {}, subtitle stream {}", "Currently playing video stream {current_video}, audio stream {current_audio}, subtitle stream {current_text}"
current_video, current_audio, current_text
); );
println!("Type any number and hit ENTER to select a different subtitle stream"); println!("Type any number and hit ENTER to select a different subtitle stream");
} }
@ -81,7 +77,7 @@ fn handle_keyboard(playbin: &gst::Element, main_loop: &glib::MainLoop) {
let n_audio = playbin.property::<i32>("n-text"); let n_audio = playbin.property::<i32>("n-text");
if index < n_audio { if index < n_audio {
println!("Setting current subtitle stream to {}", index); println!("Setting current subtitle stream to {index}");
playbin.set_property("current-text", index); playbin.set_property("current-text", index);
} else { } else {
eprintln!("Index out of bounds"); eprintln!("Index out of bounds");
@ -194,6 +190,6 @@ fn main() {
// (but not necessary in normal Cocoa applications where this is set up automatically) // (but not necessary in normal Cocoa applications where this is set up automatically)
match tutorials_common::run(tutorial_main) { match tutorials_common::run(tutorial_main) {
Ok(_) => {} Ok(_) => {}
Err(err) => eprintln!("Failed: {}", err), Err(err) => eprintln!("Failed: {err}"),
}; };
} }

View file

@ -184,6 +184,6 @@ fn main() {
// (but not necessary in normal Cocoa applications where this is set up automatically) // (but not necessary in normal Cocoa applications where this is set up automatically)
match tutorials_common::run(tutorial_main) { match tutorials_common::run(tutorial_main) {
Ok(_) => {} Ok(_) => {}
Err(err) => eprintln!("Failed: {}", err), Err(err) => eprintln!("Failed: {err}"),
}; };
} }

View file

@ -188,6 +188,6 @@ fn main() {
// (but not necessary in normal Cocoa applications where this is set up automatically) // (but not necessary in normal Cocoa applications where this is set up automatically)
match tutorials_common::run(tutorial_main) { match tutorials_common::run(tutorial_main) {
Ok(_) => {} Ok(_) => {}
Err(err) => eprintln!("Failed: {}", err), Err(err) => eprintln!("Failed: {err}"),
}; };
} }

View file

@ -192,6 +192,6 @@ fn main() {
// (but not necessary in normal Cocoa applications where this is set up automatically) // (but not necessary in normal Cocoa applications where this is set up automatically)
match tutorials_common::run(tutorial_main) { match tutorials_common::run(tutorial_main) {
Ok(_) => {} Ok(_) => {}
Err(err) => eprintln!("Failed: {}", err), Err(err) => eprintln!("Failed: {err}"),
}; };
} }

View file

@ -29,7 +29,7 @@ fn tutorial_main() -> Result<(), Error> {
for feature in list { for feature in list {
let factory = feature.downcast::<gst::ElementFactory>().unwrap(); let factory = feature.downcast::<gst::ElementFactory>().unwrap();
let name = factory.longname(); let name = factory.longname();
println!(" {}", name); println!(" {name}");
if selected_factory.is_none() && name.starts_with("GOOM") { if selected_factory.is_none() && name.starts_with("GOOM") {
selected_factory = Some(factory); selected_factory = Some(factory);
@ -41,7 +41,7 @@ fn tutorial_main() -> Result<(), Error> {
// We have now selected a factory for the visualization element // We have now selected a factory for the visualization element
let name = vis_factory.longname(); let name = vis_factory.longname();
println!("Selected {}", name); println!("Selected {name}");
let vis_plugin = vis_factory.create().build().unwrap(); let vis_plugin = vis_factory.create().build().unwrap();
// Build the pipeline // Build the pipeline
@ -82,6 +82,6 @@ fn main() {
// (but not necessary in normal Cocoa applications where this is set up automatically) // (but not necessary in normal Cocoa applications where this is set up automatically)
match tutorials_common::run(tutorial_main) { match tutorials_common::run(tutorial_main) {
Ok(_) => {} Ok(_) => {}
Err(err) => eprintln!("Failed: {}", err), Err(err) => eprintln!("Failed: {err}"),
}; };
} }

View file

@ -65,6 +65,6 @@ fn main() {
// (but not necessary in normal Cocoa applications where this is set up automatically) // (but not necessary in normal Cocoa applications where this is set up automatically)
match tutorials_common::run(tutorial_main) { match tutorials_common::run(tutorial_main) {
Ok(_) => {} Ok(_) => {}
Err(err) => eprintln!("Failed: {}", err), Err(err) => eprintln!("Failed: {err}"),
}; };
} }