Skip to content

Commit

Permalink
inline format args to please our pedantic overlords
Browse files Browse the repository at this point in the history
  • Loading branch information
donkeyteethUX committed Feb 7, 2023
1 parent f575bb5 commit 8ba7d19
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions examples/controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use v4l::prelude::*;

fn main() -> io::Result<()> {
let path = "/dev/video0";
println!("Using device: {}\n", path);
println!("Using device: {path}\n");

let dev = Device::with_path(path)?;
let controls = dev.query_controls()?;

for control in controls {
println!("{}", control);
println!("{control}");
}

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions examples/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use v4l::prelude::*;

fn main() -> io::Result<()> {
let path = "/dev/video0";
println!("Using device: {}\n", path);
println!("Using device: {path}\n");

let dev = Device::with_path(path)?;

let caps = dev.query_caps()?;
println!("Device capabilities:\n{}", caps);
println!("Device capabilities:\n{caps}");

let controls = dev.query_controls()?;
println!("Device controls:");
Expand Down
10 changes: 5 additions & 5 deletions examples/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ use v4l::video::Capture;

fn main() -> io::Result<()> {
let path = "/dev/video0";
println!("Using device: {}\n", path);
println!("Using device: {path}\n");

let dev = Device::with_path(path)?;

let format = dev.format()?;
println!("Active format:\n{}", format);
println!("Active format:\n{format}");

let params = dev.params()?;
println!("Active parameters:\n{}", params);
println!("Active parameters:\n{params}");

println!("Available formats:");
for format in dev.enum_formats()? {
println!(" {} ({})", format.fourcc, format.description);

for framesize in dev.enum_framesizes(format.fourcc)? {
for discrete in framesize.size.to_discrete() {
println!(" Size: {}", discrete);
println!(" Size: {discrete}");

for frameinterval in
dev.enum_frameintervals(framesize.fourcc, discrete.width, discrete.height)?
{
println!(" Interval: {}", frameinterval);
println!(" Interval: {frameinterval}");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/glium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use v4l::{Format, FourCC};

fn main() -> io::Result<()> {
let path = "/dev/video0";
println!("Using device: {}\n", path);
println!("Using device: {path}\n");

// Allocate 4 buffers by default
let buffer_count = 4;
Expand Down Expand Up @@ -50,8 +50,8 @@ fn main() -> io::Result<()> {
}
}

println!("Active format:\n{}", format);
println!("Active parameters:\n{}", params);
println!("Active format:\n{format}");
println!("Active parameters:\n{params}");

// Setup the GL display stuff
let event_loop = glutin::event_loop::EventLoop::new();
Expand Down
8 changes: 4 additions & 4 deletions examples/stream_capture_mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use v4l::video::Capture;

fn main() -> io::Result<()> {
let path = "/dev/video0";
println!("Using device: {}\n", path);
println!("Using device: {path}\n");

// Capture 4 frames by default
let count = 4;
Expand All @@ -19,8 +19,8 @@ fn main() -> io::Result<()> {
let dev = Device::with_path(path)?;
let format = dev.format()?;
let params = dev.params()?;
println!("Active format:\n{}", format);
println!("Active parameters:\n{}", params);
println!("Active format:\n{format}");
println!("Active parameters:\n{params}");

// Setup a buffer stream and grab a frame, then print its data
let mut stream = MmapStream::with_buffers(&dev, Type::VideoCapture, buffer_count)?;
Expand Down Expand Up @@ -54,7 +54,7 @@ fn main() -> io::Result<()> {

println!();
println!("FPS: {}", count as f64 / start.elapsed().as_secs_f64());
println!("MB/s: {}", megabytes_ps);
println!("MB/s: {megabytes_ps}");

Ok(())
}
8 changes: 4 additions & 4 deletions examples/stream_capture_userptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use v4l::video::Capture;

fn main() -> io::Result<()> {
let path = "/dev/video0";
println!("Using device: {}\n", path);
println!("Using device: {path}\n");

// Capture 4 frames by default
let count = 4;
Expand All @@ -19,8 +19,8 @@ fn main() -> io::Result<()> {
let dev = Device::with_path(path)?;
let format = dev.format()?;
let params = dev.params()?;
println!("Active format:\n{}", format);
println!("Active parameters:\n{}", params);
println!("Active format:\n{format}");
println!("Active parameters:\n{params}");

// Setup a buffer stream and grab a frame, then print its data
let mut stream = UserptrStream::with_buffers(&dev, Type::VideoCapture, buffer_count)?;
Expand Down Expand Up @@ -54,7 +54,7 @@ fn main() -> io::Result<()> {

println!();
println!("FPS: {}", count as f64 / start.elapsed().as_secs_f64());
println!("MB/s: {}", megabytes_ps);
println!("MB/s: {megabytes_ps}");

Ok(())
}
6 changes: 3 additions & 3 deletions examples/stream_forward_mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use v4l::video::{Capture, Output};

fn main() -> io::Result<()> {
let source = "/dev/video0";
println!("Using source device: {}\n", source);
println!("Using source device: {source}\n");

// Determine which device to use
let sink = "/dev/video1";
println!("Using sink device: {}\n", sink);
println!("Using sink device: {sink}\n");

// Capture 4 frames by default
let count = 4;
Expand Down Expand Up @@ -95,7 +95,7 @@ fn main() -> io::Result<()> {

println!();
println!("FPS: {}", count as f64 / start.elapsed().as_secs_f64());
println!("MB/s: {}", megabytes_ps);
println!("MB/s: {megabytes_ps}");

Ok(())
}
4 changes: 2 additions & 2 deletions src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ impl fmt::Display for MenuItem {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
MenuItem::Name(name) => {
write!(f, "{}", name)?;
write!(f, "{name}")?;
}
MenuItem::Value(value) => {
write!(f, "{}", value)?;
write!(f, "{value}")?;
}
}
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/format/fourcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl fmt::Display for FourCC {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let string = str::from_utf8(&self.repr);
if let Ok(string) = string {
write!(f, "{}", string)?;
write!(f, "{string}")?;
}
Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions src/frameinterval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub enum FrameIntervalEnum {
impl fmt::Display for FrameIntervalEnum {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FrameIntervalEnum::Discrete(val) => write!(f, "Discrete({})", val)?,
FrameIntervalEnum::Stepwise(val) => write!(f, "Stepwise({})", val)?,
FrameIntervalEnum::Discrete(val) => write!(f, "Discrete({val})")?,
FrameIntervalEnum::Stepwise(val) => write!(f, "Stepwise({val})")?,
}

Ok(())
Expand All @@ -56,7 +56,7 @@ impl TryFrom<v4l2_frmivalenum> for FrameIntervalEnum {
step: Fraction::from(desc.__bindgen_anon_1.stepwise.step),
})
}),
typ => Err(format!("Unknown frame size type: {}", typ)),
typ => Err(format!("Unknown frame size type: {typ}")),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/framesize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ impl FrameSizeEnum {
impl fmt::Display for FrameSizeEnum {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FrameSizeEnum::Discrete(val) => write!(f, "Discrete({})", val)?,
FrameSizeEnum::Stepwise(val) => write!(f, "Stepwise({})", val)?,
FrameSizeEnum::Discrete(val) => write!(f, "Discrete({val})")?,
FrameSizeEnum::Stepwise(val) => write!(f, "Stepwise({val})")?,
}

Ok(())
Expand Down Expand Up @@ -84,7 +84,7 @@ impl TryFrom<v4l2_frmsizeenum> for FrameSizeEnum {
step_height: desc.__bindgen_anon_1.stepwise.step_height,
})
}),
typ => Err(format!("Unknown frame size type: {}", typ)),
typ => Err(format!("Unknown frame size type: {typ}")),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Timestamp {
impl fmt::Display for Timestamp {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let floating: f64 = self.sec as f64 + self.usec as f64 / 1_000_000.0;
write!(f, "{} [s]", floating)
write!(f, "{floating} [s]")
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/v4l2/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mod detail {
prot,
flags,
fd,
offset as i64,
offset,
)
}
pub unsafe fn munmap(start: *mut std::os::raw::c_void, length: usize) -> std::os::raw::c_int {
Expand Down

0 comments on commit 8ba7d19

Please sign in to comment.