Migrate to Rust edition 2024

This commit is contained in:
2025-03-04 22:59:28 -07:00
parent fb3542f445
commit d6969045be
38 changed files with 116 additions and 125 deletions

View File

@@ -4,7 +4,7 @@
//! For now, this only adds a --version/-V option which causes early-exit.
use std::ffi::OsStr;
use argp::{parser::ParseGlobalOptions, EarlyExit, FromArgs, TopLevelCommand};
use argp::{EarlyExit, FromArgs, TopLevelCommand, parser::ParseGlobalOptions};
struct ArgsOrVersion<T>(T)
where T: FromArgs;

View File

@@ -47,7 +47,9 @@ pub fn run(args: Args) -> nod::Result<()> {
(false, true) => PartitionEncryption::ForceEncrypted,
(false, false) => PartitionEncryption::Original,
(true, true) => {
return Err(nod::Error::Other("Both --decrypt and --encrypt specified".to_string()))
return Err(nod::Error::Other(
"Both --decrypt and --encrypt specified".to_string(),
));
}
},
preloader_threads: 4,
@@ -70,7 +72,7 @@ pub fn run(args: Args) -> nod::Result<()> {
return Err(nod::Error::Other(format!(
"Unknown file extension: {}",
path_display(&args.out)
)))
)));
}
None => Format::Iso,
};

View File

@@ -7,9 +7,9 @@ use std::{
use argp::FromArgs;
use indicatif::{ProgressBar, ProgressState, ProgressStyle};
use nod::{
Result, ResultContext,
read::{DiscOptions, DiscReader, PartitionEncryption},
write::{DiscWriter, FormatOptions, ProcessOptions},
Result, ResultContext,
};
use crate::util::{redump, redump::GameResult};

View File

@@ -7,10 +7,10 @@ use std::{
use argp::FromArgs;
use nod::{
ResultContext,
common::PartitionKind,
disc::fst::{Fst, Node},
read::{DiscOptions, DiscReader, PartitionMeta, PartitionOptions, PartitionReader},
ResultContext,
};
use size::{Base, Size};
use zerocopy::IntoBytes;

View File

@@ -10,11 +10,12 @@ use std::{
use argp::FromArgs;
use nod::{
ResultContext,
build::gc::{FileCallback, FileInfo, GCPartitionBuilder, PartitionOverrides},
common::PartitionKind,
disc::{
fst::Fst, BootHeader, DiscHeader, BB2_OFFSET, BI2_SIZE, BOOT_SIZE, MINI_DVD_SIZE,
SECTOR_SIZE,
BB2_OFFSET, BI2_SIZE, BOOT_SIZE, BootHeader, DiscHeader, MINI_DVD_SIZE, SECTOR_SIZE,
fst::Fst,
},
read::{
DiscOptions, DiscReader, PartitionEncryption, PartitionMeta, PartitionOptions,
@@ -22,7 +23,6 @@ use nod::{
},
util::lfg::LaggedFibonacci,
write::{DiscWriter, FormatOptions, ProcessOptions},
ResultContext,
};
use tracing::{debug, error, info, warn};
use zerocopy::{FromBytes, FromZeros};
@@ -188,7 +188,7 @@ pub fn run(args: Args) -> nod::Result<()> {
}
Err(e) => {
return Err(e)
.context(format!("Failed to get metadata for {}", file_path.display()))
.context(format!("Failed to get metadata for {}", file_path.display()));
}
};
if metadata.is_dir() {

View File

@@ -1,6 +1,6 @@
pub mod convert;
pub mod dat;
pub mod extract;
pub mod gen;
pub mod r#gen;
pub mod info;
pub mod verify;

View File

@@ -41,7 +41,9 @@ pub fn run(args: Args) -> nod::Result<()> {
(false, true) => PartitionEncryption::ForceEncrypted,
(false, false) => PartitionEncryption::Original,
(true, true) => {
return Err(nod::Error::Other("Both --decrypt and --encrypt specified".to_string()))
return Err(nod::Error::Other(
"Both --decrypt and --encrypt specified".to_string(),
));
}
},
preloader_threads: 4.min(cpus),

View File

@@ -13,7 +13,7 @@ pub enum SubCommand {
Dat(cmd::dat::Args),
Extract(cmd::extract::Args),
// Gen(cmd::gen::Args),
GenTest(cmd::gen::TestArgs),
GenTest(cmd::r#gen::TestArgs),
Info(cmd::info::Args),
Verify(cmd::verify::Args),
}
@@ -24,7 +24,7 @@ pub fn run(command: SubCommand) -> nod::Result<()> {
SubCommand::Dat(c_args) => cmd::dat::run(c_args),
SubCommand::Extract(c_args) => cmd::extract::run(c_args),
// SubCommand::Gen(c_args) => cmd::gen::run(c_args),
SubCommand::GenTest(c_args) => cmd::gen::run_test(c_args),
SubCommand::GenTest(c_args) => cmd::r#gen::run_test(c_args),
SubCommand::Info(c_args) => cmd::info::run(c_args),
SubCommand::Verify(c_args) => cmd::verify::run(c_args),
}

View File

@@ -10,7 +10,7 @@ use std::{env, error::Error, ffi::OsStr, fmt, path::PathBuf, str::FromStr};
use argp::{FromArgValue, FromArgs};
use enable_ansi_support::enable_ansi_support;
use nodtool::{run, SubCommand};
use nodtool::{SubCommand, run};
use supports_color::Stream;
#[derive(FromArgs, Debug)]
@@ -93,7 +93,7 @@ fn main() {
// Try to enable ANSI support on Windows.
let _ = enable_ansi_support();
// Disable isatty check for supports-color. (e.g. when used with ninja)
env::set_var("IGNORE_IS_TERMINAL", "1");
unsafe { env::set_var("IGNORE_IS_TERMINAL", "1") };
supports_color::on(Stream::Stdout).is_some_and(|c| c.has_basic)
};

View File

@@ -5,7 +5,7 @@ pub mod shared;
use std::{
fmt,
fmt::Write,
path::{Path, MAIN_SEPARATOR},
path::{MAIN_SEPARATOR, Path},
};
pub fn path_display(path: &Path) -> PathDisplay { PathDisplay { path } }

View File

@@ -7,11 +7,11 @@ use std::{
use indicatif::{ProgressBar, ProgressState, ProgressStyle};
use nod::{
Result, ResultContext,
common::Compression,
disc::DiscHeader,
read::{DiscMeta, DiscOptions, DiscReader, PartitionEncryption},
write::{DiscWriter, DiscWriterWeight, FormatOptions, ProcessOptions},
Result, ResultContext,
};
use size::Size;