Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions cargo-progenitor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ enum InterfaceArg {
impl From<InterfaceArg> for InterfaceStyle {
fn from(arg: InterfaceArg) -> Self {
match arg {
InterfaceArg::Positional => InterfaceStyle::Positional,
InterfaceArg::Builder => InterfaceStyle::Builder,
InterfaceArg::Positional => Self::Positional,
InterfaceArg::Builder => Self::Builder,
}
}
}
Expand All @@ -80,8 +80,8 @@ enum TagArg {
impl From<TagArg> for TagStyle {
fn from(arg: TagArg) -> Self {
match arg {
TagArg::Merged => TagStyle::Merged,
TagArg::Separate => TagStyle::Separate,
TagArg::Merged => Self::Merged,
TagArg::Separate => Self::Separate,
}
}
}
Expand All @@ -92,7 +92,7 @@ fn reformat_code(input: String) -> String {
wrap_comments: Some(true),
..Default::default()
};
space_out_items(rustfmt_wrapper::rustfmt_config(config, input).unwrap()).unwrap()
space_out_items(&rustfmt_wrapper::rustfmt_config(config, input).unwrap()).unwrap()
}

fn save<P>(p: P, data: &str) -> Result<()>
Expand Down Expand Up @@ -131,7 +131,7 @@ fn main() -> Result<()> {
println!("-----------------------------------------------------");
for (idx, type_entry) in type_space.iter_types().enumerate() {
let n = type_entry.describe();
println!("{:>4} {}", idx, n);
println!("{idx:>4} {n}");
}
println!("-----------------------------------------------------");
println!();
Expand All @@ -156,7 +156,7 @@ fn main() -> Result<()> {
name, version, &args.license_name,
);
if let Some(registry_name) = args.registry_name {
tomlout.extend(format!("publish = [\"{}\"]\n", registry_name).chars());
tomlout.extend(format!("publish = [\"{registry_name}\"]\n").chars());
}
tomlout.extend(
format!(
Expand All @@ -178,7 +178,7 @@ fn main() -> Result<()> {

// Create the Rust source file containing the generated client:
let lib_code = if args.include_client {
format!("mod progenitor_client;\n\n{}", api_code)
format!("mod progenitor_client;\n\n{api_code}")
} else {
api_code.to_string()
};
Expand All @@ -198,7 +198,7 @@ fn main() -> Result<()> {
}

Err(e) => {
println!("gen fail: {:?}", e);
println!("gen fail: {e:?}");
bail!("generation experienced errors");
}
}
Expand Down Expand Up @@ -265,7 +265,7 @@ pub fn dependencies(builder: Generator, include_client: bool) -> Vec<String> {
} else {
"*"
};
let client_version_dep = format!("progenitor-client = \"{}\"", crate_version);
let client_version_dep = format!("progenitor-client = \"{crate_version}\"");
deps.push(client_version_dep);
}

Expand Down
5 changes: 2 additions & 3 deletions cargo-progenitor/tests/test_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright 2025 Oxide Computer Company

use assert_cmd::Command;
use assert_cmd::cargo;

#[test]
fn test_help() {
Command::cargo_bin("cargo-progenitor")
.unwrap()
cargo::cargo_bin_cmd!("cargo-progenitor")
.arg("progenitor")
.arg("--help")
.assert()
Expand Down
2 changes: 1 addition & 1 deletion example-build/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{

fn main() {
let src = "../sample_openapi/keeper.json";
println!("cargo:rerun-if-changed={}", src);
println!("cargo:rerun-if-changed={src}");
let file = File::open(src).unwrap();
let spec = serde_json::from_reader(file).unwrap();
let mut generator = progenitor::Generator::default();
Expand Down
4 changes: 2 additions & 2 deletions example-build/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ fn main() {
let _ = client.enrol(
"auth-token",
&types::EnrolBody {
host: "".to_string(),
key: "".to_string(),
host: String::new(),
key: String::new(),
},
);
}
2 changes: 1 addition & 1 deletion example-macro/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use progenitor::generate_api;
generate_api!(
spec = "../sample_openapi/keeper.json",
pre_hook = (|request| {
println!("doing this {:?}", request);
println!("doing this {request:?}");
}),
pre_hook_async = crate::add_auth_headers,
post_hook = crate::all_done,
Expand Down
2 changes: 1 addition & 1 deletion example-wasm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{

fn main() {
let src = "../sample_openapi/keeper.json";
println!("cargo:rerun-if-changed={}", src);
println!("cargo:rerun-if-changed={src}");
let file = File::open(src).unwrap();
let spec = serde_json::from_reader(file).unwrap();
let mut generator = progenitor::Generator::default();
Expand Down
4 changes: 2 additions & 2 deletions example-wasm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ fn main() {
let _ = client.enrol(
"auth-token",
&types::EnrolBody {
host: "".to_string(),
key: "".to_string(),
host: String::new(),
key: String::new(),
},
);
}
72 changes: 36 additions & 36 deletions progenitor-client/src/progenitor_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type InnerByteStream = std::pin::Pin<Box<dyn Stream<Item = reqwest::Result<Bytes
pub struct ByteStream(InnerByteStream);

impl ByteStream {
/// Creates a new ByteStream
/// Creates a new [`ByteStream`]
///
/// Useful for generating test fixtures.
pub fn new(inner: InnerByteStream) -> Self {
Expand Down Expand Up @@ -355,14 +355,14 @@ impl<E> Error<E> {
/// Returns the status code, if the error was generated from a response.
pub fn status(&self) -> Option<reqwest::StatusCode> {
match self {
Error::InvalidRequest(_) => None,
Error::Custom(_) => None,
Error::CommunicationError(e) => e.status(),
Error::ErrorResponse(rv) => Some(rv.status()),
Error::InvalidUpgrade(e) => e.status(),
Error::ResponseBodyError(e) => e.status(),
Error::InvalidResponsePayload(_, _) => None,
Error::UnexpectedResponse(r) => Some(r.status()),
Self::InvalidRequest(_) => None,
Self::Custom(_) => None,
Self::CommunicationError(e) => e.status(),
Self::ErrorResponse(rv) => Some(rv.status()),
Self::InvalidUpgrade(e) => e.status(),
Self::ResponseBodyError(e) => e.status(),
Self::InvalidResponsePayload(_, _) => None,
Self::UnexpectedResponse(r) => Some(r.status()),
}
}

Expand All @@ -372,10 +372,10 @@ impl<E> Error<E> {
/// various error response bodies.
pub fn into_untyped(self) -> Error {
match self {
Error::InvalidRequest(s) => Error::InvalidRequest(s),
Error::Custom(s) => Error::Custom(s),
Error::CommunicationError(e) => Error::CommunicationError(e),
Error::ErrorResponse(ResponseValue {
Self::InvalidRequest(s) => Error::InvalidRequest(s),
Self::Custom(s) => Error::Custom(s),
Self::CommunicationError(e) => Error::CommunicationError(e),
Self::ErrorResponse(ResponseValue {
inner: _,
status,
headers,
Expand All @@ -384,10 +384,10 @@ impl<E> Error<E> {
status,
headers,
}),
Error::InvalidUpgrade(e) => Error::InvalidUpgrade(e),
Error::ResponseBodyError(e) => Error::ResponseBodyError(e),
Error::InvalidResponsePayload(b, e) => Error::InvalidResponsePayload(b, e),
Error::UnexpectedResponse(r) => Error::UnexpectedResponse(r),
Self::InvalidUpgrade(e) => Error::InvalidUpgrade(e),
Self::ResponseBodyError(e) => Error::ResponseBodyError(e),
Self::InvalidResponsePayload(b, e) => Error::InvalidResponsePayload(b, e),
Self::UnexpectedResponse(r) => Error::UnexpectedResponse(r),
}
}
}
Expand Down Expand Up @@ -416,30 +416,30 @@ where
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::InvalidRequest(s) => {
write!(f, "Invalid Request: {}", s)?;
Self::InvalidRequest(s) => {
write!(f, "Invalid Request: {s}")?;
}
Error::CommunicationError(e) => {
write!(f, "Communication Error: {}", e)?;
Self::CommunicationError(e) => {
write!(f, "Communication Error: {e}")?;
}
Error::ErrorResponse(rve) => {
Self::ErrorResponse(rve) => {
write!(f, "Error Response: ")?;
rve.fmt_info(f)?;
}
Error::InvalidUpgrade(e) => {
write!(f, "Invalid Response Upgrade: {}", e)?;
Self::InvalidUpgrade(e) => {
write!(f, "Invalid Response Upgrade: {e}")?;
}
Error::ResponseBodyError(e) => {
write!(f, "Invalid Response Body Bytes: {}", e)?;
Self::ResponseBodyError(e) => {
write!(f, "Invalid Response Body Bytes: {e}")?;
}
Error::InvalidResponsePayload(b, e) => {
write!(f, "Invalid Response Payload ({:?}): {}", b, e)?;
Self::InvalidResponsePayload(b, e) => {
write!(f, "Invalid Response Payload ({b:?}): {e}")?;
}
Error::UnexpectedResponse(r) => {
write!(f, "Unexpected Response: {:?}", r)?;
Self::UnexpectedResponse(r) => {
write!(f, "Unexpected Response: {r:?}")?;
}
Error::Custom(s) => {
write!(f, "Error: {}", s)?;
Self::Custom(s) => {
write!(f, "Error: {s}")?;
}
}

Expand Down Expand Up @@ -497,10 +497,10 @@ where
{
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Error::CommunicationError(e) => Some(e),
Error::InvalidUpgrade(e) => Some(e),
Error::ResponseBodyError(e) => Some(e),
Error::InvalidResponsePayload(_b, e) => Some(e),
Self::CommunicationError(e) => Some(e),
Self::InvalidUpgrade(e) => Some(e),
Self::ResponseBodyError(e) => Some(e),
Self::InvalidResponsePayload(_b, e) => Some(e),
_ => None,
}
}
Expand Down
Loading