diff --git a/src/disc/dvd.rs b/src/disc/dvd.rs index e7c8f07..99915b8 100644 --- a/src/disc/dvd.rs +++ b/src/disc/dvd.rs @@ -59,7 +59,7 @@ impl Disc { 2 => "stereo".to_string(), 6 => "5.1".to_string(), 8 => "7.1".to_string(), - n => format!("{}ch", n), + n => format!("{n}ch"), }; let sample_rate = match a.sample_rate { 48000 => "48kHz".to_string(), diff --git a/src/disc/mod.rs b/src/disc/mod.rs index aacb010..5e04bee 100644 --- a/src/disc/mod.rs +++ b/src/disc/mod.rs @@ -333,7 +333,7 @@ impl DiscTitle { pub fn duration_display(&self) -> String { let hrs = (self.duration_secs / 3600.0) as u32; let mins = ((self.duration_secs % 3600.0) / 60.0) as u32; - format!("{}h {:02}m", hrs, mins) + format!("{hrs}h {mins:02}m") } /// Size in GB @@ -761,7 +761,7 @@ pub(crate) fn detect_max_batch_sectors(device_path: &str) -> u16 { // For sg devices, find the corresponding block device name let block_name = if dev_name.starts_with("sg") { - let block_dir = format!("/sys/class/scsi_generic/{}/device/block", dev_name); + let block_dir = format!("/sys/class/scsi_generic/{dev_name}/device/block"); std::fs::read_dir(&block_dir) .ok() .and_then(|mut entries| entries.next()) @@ -772,7 +772,7 @@ pub(crate) fn detect_max_batch_sectors(device_path: &str) -> u16 { }; if let Some(bname) = block_name { - let sysfs_path = format!("/sys/block/{}/queue/max_hw_sectors_kb", bname); + let sysfs_path = format!("/sys/block/{bname}/queue/max_hw_sectors_kb"); if let Ok(content) = std::fs::read_to_string(&sysfs_path) { if let Ok(kb) = content.trim().parse::() { // Convert KB to sectors (1 sector = 2 KB = 2048 bytes) @@ -1045,7 +1045,7 @@ fn format_channels(audio_format: u8) -> String { 3 => "stereo".into(), 6 => "5.1".into(), 12 => "7.1".into(), - _ if audio_format > 0 => format!("{}ch", audio_format), + _ if audio_format > 0 => format!("{audio_format}ch"), _ => String::new(), } } diff --git a/src/drive/linux.rs b/src/drive/linux.rs index d397e02..71e27bb 100644 --- a/src/drive/linux.rs +++ b/src/drive/linux.rs @@ -6,7 +6,7 @@ use crate::identity::DriveId; pub fn find_drives() -> Vec<(String, DriveId)> { let mut drives = Vec::new(); for i in 0..16 { - let path = format!("/dev/sg{}", i); + let path = format!("/dev/sg{i}"); if !std::path::Path::new(&path).exists() { continue; } @@ -40,8 +40,7 @@ pub fn resolve_device(path: &str) -> Result<(String, Option)> { && sg_id.serial_number == sr_id.serial_number { let warning = format!( - "{} is a block device (sr) — using {} (sg) for raw access", - path, sg_path + "{path} is a block device (sr) — using {sg_path} (sg) for raw access" ); return Ok((sg_path, Some(warning))); } @@ -49,8 +48,7 @@ pub fn resolve_device(path: &str) -> Result<(String, Option)> { return Ok(( path.to_string(), Some(format!( - "{} is a block device (sr) — no matching sg device found", - path + "{path} is a block device (sr) — no matching sg device found" )), )); } diff --git a/src/ifo.rs b/src/ifo.rs index 5432b97..77a0e6d 100644 --- a/src/ifo.rs +++ b/src/ifo.rs @@ -265,7 +265,7 @@ fn parse_vts( vts_number: u8, titles_info: &[(u16, u8)], ) -> Result { - let path = format!("/VIDEO_TS/VTS_{:02}_0.IFO", vts_number); + let path = format!("/VIDEO_TS/VTS_{vts_number:02}_0.IFO"); let vts_data = udf.read_file(reader, &path)?; // Validate VTS magic diff --git a/src/keydb.rs b/src/keydb.rs index b53d229..b1fc039 100644 --- a/src/keydb.rs +++ b/src/keydb.rs @@ -83,7 +83,7 @@ fn http_get(url: &str) -> Result> { let (mut host, mut port, mut path) = parse_url(url)?; for _ in 0..5 { - let addr = format!("{}:{}", host, port); + let addr = format!("{host}:{port}"); let mut stream = TcpStream::connect(&addr).map_err(|_| Error::KeydbConnect { host: host.clone() })?; stream @@ -91,8 +91,7 @@ fn http_get(url: &str) -> Result> { .ok(); let request = format!( - "GET {} HTTP/1.1\r\nHost: {}\r\nConnection: close\r\nAccept-Encoding: identity\r\n\r\n", - path, host + "GET {path} HTTP/1.1\r\nHost: {host}\r\nConnection: close\r\nAccept-Encoding: identity\r\n\r\n" ); stream .write_all(request.as_bytes()) diff --git a/src/labels/criterion.rs b/src/labels/criterion.rs index 5588d1b..b4a5a29 100644 --- a/src/labels/criterion.rs +++ b/src/labels/criterion.rs @@ -174,8 +174,8 @@ fn parse_playback_config(xml: &str, map: &mut HashMap) { } fn extract_tag(xml: &str, tag: &str) -> Option { - let open = format!("<{}>", tag); - let close = format!("", tag); + let open = format!("<{tag}>"); + let close = format!(""); let start = xml.find(&open)? + open.len(); let end = xml[start..].find(&close)? + start; Some(xml[start..end].trim().to_string()) diff --git a/src/labels/paramount.rs b/src/labels/paramount.rs index 717b980..cbd9bc5 100644 --- a/src/labels/paramount.rs +++ b/src/labels/paramount.rs @@ -140,7 +140,7 @@ fn find_feature_playlist(xml: &str) -> Option { /// Extract an XML attribute value from an element string. fn extract_attr(element: &str, name: &str) -> Option { - let needle = format!("{}=\"", name); + let needle = format!("{name}=\""); let start = element.find(&needle)? + needle.len(); let end = element[start..].find('"')? + start; Some(element[start..end].to_string()) diff --git a/src/mux/codec/dvdsub.rs b/src/mux/codec/dvdsub.rs index bb5102a..2d40ba4 100644 --- a/src/mux/codec/dvdsub.rs +++ b/src/mux/codec/dvdsub.rs @@ -87,7 +87,7 @@ pub fn format_palette(palette: &[[u8; 4]]) -> Vec { let mut parts: Vec = Vec::with_capacity(palette.len()); for color in palette { let [r, g, b] = ycbcr_to_rgb(color); - parts.push(format!("{:02x}{:02x}{:02x}", r, g, b)); + parts.push(format!("{r:02x}{g:02x}{b:02x}")); } let line = format!("palette: {}\n", parts.join(", ")); line.into_bytes() diff --git a/src/mux/ebml.rs b/src/mux/ebml.rs index 06069b2..e7601ef 100644 --- a/src/mux/ebml.rs +++ b/src/mux/ebml.rs @@ -356,7 +356,7 @@ pub const SEEK_POSITION: u32 = 0x53AC; // Segment Info pub const INFO: u32 = 0x1549_A966; -pub const TIMESTAMP_SCALE: u32 = 0x2AD7B1; +pub const TIMESTAMP_SCALE: u32 = 0x2A_D7B1; pub const DURATION: u32 = 0x4489; pub const MUXING_APP: u32 = 0x4D80; pub const WRITING_APP: u32 = 0x5741; @@ -371,11 +371,11 @@ pub const TRACK_TYPE: u32 = 0x83; pub const FLAG_LACING: u32 = 0x9C; pub const FLAG_DEFAULT: u32 = 0x88; pub const FLAG_FORCED: u32 = 0x55AA; -pub const LANGUAGE: u32 = 0x22B59C; +pub const LANGUAGE: u32 = 0x22_B59C; pub const CODEC_ID: u32 = 0x86; pub const CODEC_PRIVATE: u32 = 0x63A2; pub const TRACK_NAME: u32 = 0x536E; -pub const DEFAULT_DURATION: u32 = 0x23E383; +pub const DEFAULT_DURATION: u32 = 0x23_E383; // Video pub const VIDEO: u32 = 0xE0; diff --git a/src/mux/iso.rs b/src/mux/iso.rs index 30f7aff..d49591e 100644 --- a/src/mux/iso.rs +++ b/src/mux/iso.rs @@ -30,7 +30,7 @@ pub struct IsoSectorReader { impl IsoSectorReader { pub fn open(path: &str) -> io::Result { let file = File::open(Path::new(path)) - .map_err(|e| io::Error::new(e.kind(), format!("iso://{}: {}", path, e)))?; + .map_err(|e| io::Error::new(e.kind(), format!("iso://{path}: {e}")))?; let size = file.metadata()?.len(); let capacity = (size / SECTOR_SIZE) as u32; Ok(Self { file, capacity }) @@ -123,7 +123,7 @@ impl IsoStream { /// Create an ISO file for writing. pub fn create(path: &str) -> io::Result { let file = File::create(Path::new(path)) - .map_err(|e| io::Error::new(e.kind(), format!("iso://{}: {}", path, e)))?; + .map_err(|e| io::Error::new(e.kind(), format!("iso://{path}: {e}")))?; let buf_writer = io::BufWriter::with_capacity(4 * 1024 * 1024, file); let iso_writer = IsoWriter::new(buf_writer, "FREEMKV", "00001.m2ts"); diff --git a/src/mux/isowriter.rs b/src/mux/isowriter.rs index 2cd12d1..5ec81f7 100644 --- a/src/mux/isowriter.rs +++ b/src/mux/isowriter.rs @@ -197,7 +197,7 @@ impl IsoWriter { // Partition starting location at offset 188 pd[188..192].copy_from_slice(&PARTITION_START.to_le_bytes()); // Partition length (large enough for everything) - let part_len: u32 = 0xFFFFFFFF; + let part_len: u32 = 0xFFFF_FFFF; pd[192..196].copy_from_slice(&part_len.to_le_bytes()); self.writer.write_all(&pd)?; diff --git a/src/mux/mkv.rs b/src/mux/mkv.rs index de89a47..0f8442d 100644 --- a/src/mux/mkv.rs +++ b/src/mux/mkv.rs @@ -183,7 +183,7 @@ impl MkvMuxer { for (i, track) in tracks.iter().enumerate() { let entry_pos = ebml::start_master(&mut writer, ebml::TRACK_ENTRY)?; ebml::write_uint(&mut writer, ebml::TRACK_NUMBER, (i + 1) as u64)?; - ebml::write_uint(&mut writer, ebml::TRACK_UID, (i + 1) as u64 | 0x1000000)?; + ebml::write_uint(&mut writer, ebml::TRACK_UID, (i + 1) as u64 | 0x100_0000)?; ebml::write_uint(&mut writer, ebml::TRACK_TYPE, track.track_type)?; ebml::write_uint(&mut writer, ebml::FLAG_LACING, 0)?; ebml::write_string(&mut writer, ebml::CODEC_ID, track.codec_id)?; @@ -432,7 +432,7 @@ fn parse_resolution(s: &str) -> (u32, u32) { fn parse_sample_rate(s: &str) -> f64 { if s.contains("192") { - 192000.0 + 192_000.0 } else if s.contains("96") { 96000.0 } else { diff --git a/src/mux/mkvstream.rs b/src/mux/mkvstream.rs index 7fd4fb2..3ca743d 100644 --- a/src/mux/mkvstream.rs +++ b/src/mux/mkvstream.rs @@ -512,7 +512,7 @@ fn parse_track(r: &mut (impl Read + Seek), size: u64) -> io::Result Codec::DvdSub, _ => Codec::Unknown(0), }; - let res = format!("{}p", ph); + let res = format!("{ph}p"); let chs: String = match ch { 8 => "7.1", 6 => "5.1", diff --git a/src/mux/resolve.rs b/src/mux/resolve.rs index 79c2e36..c79785d 100644 --- a/src/mux/resolve.rs +++ b/src/mux/resolve.rs @@ -104,8 +104,7 @@ fn validate_file_path(path: &str, scheme: &str) -> io::Result<()> { return Err(io::Error::new( io::ErrorKind::InvalidInput, format!( - "{}:// requires a file path (e.g. {}://movie.{})", - scheme, scheme, scheme + "{scheme}:// requires a file path (e.g. {scheme}://movie.{scheme})" ), )); } @@ -114,8 +113,7 @@ fn validate_file_path(path: &str, scheme: &str) -> io::Result<()> { return Err(io::Error::new( io::ErrorKind::InvalidInput, format!( - "{}://{} is not a valid file path — must include a filename", - scheme, path + "{scheme}://{path} is not a valid file path — must include a filename" ), )); } @@ -134,8 +132,7 @@ fn validate_network_addr(addr: &str) -> io::Result<()> { return Err(io::Error::new( io::ErrorKind::InvalidInput, format!( - "network://{} missing port — use network://{}:PORT", - addr, addr + "network://{addr} missing port — use network://{addr}:PORT" ), )); } diff --git a/src/udf.rs b/src/udf.rs index 14b90ba..e03de9d 100644 --- a/src/udf.rs +++ b/src/udf.rs @@ -288,7 +288,7 @@ impl UdfFs { let raw_len = u32::from_le_bytes([icb[off], icb[off + 1], icb[off + 2], icb[off + 3]]); let extent_type = raw_len >> 30; - let data_len = raw_len & 0x3FFFFFFF; + let data_len = raw_len & 0x3FFF_FFFF; let data_lba = u32::from_le_bytes([icb[off + 4], icb[off + 5], icb[off + 6], icb[off + 7]]); @@ -455,7 +455,7 @@ pub fn read_filesystem(reader: &mut dyn SectorReader) -> Result { meta_icb[ad_off + 1], meta_icb[ad_off + 2], meta_icb[ad_off + 3], - ]) & 0x3FFFFFFF; + ]) & 0x3FFF_FFFF; metadata_size_bytes = ad_len; let ad_pos = u32::from_le_bytes([ meta_icb[ad_off + 4], @@ -543,7 +543,7 @@ fn read_directory( icb[ad_off + 1], icb[ad_off + 2], icb[ad_off + 3], - ]) & 0x3FFFFFFF; + ]) & 0x3FFF_FFFF; let pos = u32::from_le_bytes([ icb[ad_off + 4], icb[ad_off + 5], @@ -565,7 +565,7 @@ fn read_directory( icb[ad_off + 1], icb[ad_off + 2], icb[ad_off + 3], - ]) & 0x3FFFFFFF; + ]) & 0x3FFF_FFFF; let pos = u32::from_le_bytes([ icb[ad_off + 4], icb[ad_off + 5],