Skip to content

Commit

Permalink
chore: Unbreak release
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Oct 17, 2024
1 parent 40a0b2a commit 678d6fc
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
7 changes: 7 additions & 0 deletions hugr-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ clio = { workspace = true, features = ["clap-parse"] }
[lints]
workspace = true

[package.metadata.cargo-semver-checks.lints]
workspace = true
# Temporarily disabled due to Package being moved to `hugr-core` triggering an error in rustdoc
# https://github.com/obi1kenobi/cargo-semver-checks/issues/355
enum_missing = "warn"
struct_missing = "warn"

[dev-dependencies]
assert_cmd = { workspace = true }
assert_fs = { workspace = true }
Expand Down
17 changes: 16 additions & 1 deletion hugr-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub mod mermaid;
pub mod validate;

// TODO: Deprecated re-export. Remove on a breaking release.
#[doc(inline)]
#[deprecated(since = "0.13.2", note = "Use `hugr::package::Package` instead.")]
pub use hugr::package::Package;

/// CLI arguments.
Expand Down Expand Up @@ -109,7 +111,7 @@ impl PackageOrHugr {
reg: &mut ExtensionRegistry,
) -> Result<(), PackageValidationError> {
match self {
PackageOrHugr::Package(pkg) => pkg.validate(reg),
PackageOrHugr::Package(pkg) => pkg.update_validate(reg),
PackageOrHugr::Hugr(hugr) => hugr.update_validate(reg).map_err(Into::into),
}
}
Expand All @@ -125,4 +127,17 @@ impl HugrArgs {
let pkg = serde_json::from_value::<Package>(val.clone())?;
Ok(PackageOrHugr::Package(pkg))
}

/// Read either a package from the input.
///
/// deprecated: use [HugrArgs::get_package_or_hugr] instead.
#[deprecated(
since = "0.13.2",
note = "Use `HugrArgs::get_package_or_hugr` instead."
)]
pub fn get_package(&mut self) -> Result<Package, CliError> {
let val: serde_json::Value = serde_json::from_reader(&mut self.input)?;
let pkg = serde_json::from_value::<Package>(val.clone())?;
Ok(pkg)
}
}
8 changes: 8 additions & 0 deletions hugr-cli/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ use hugr::{extension::ExtensionRegistry, Extension, Hugr};

use crate::{CliError, HugrArgs};

// TODO: Deprecated re-export. Remove on a breaking release.
#[doc(inline)]
#[deprecated(
since = "0.13.2",
note = "Use `hugr::package::PackageValidationError` instead."
)]
pub use hugr::package::PackageValidationError as ValError;

/// Validate and visualise a HUGR file.
#[derive(Parser, Debug)]
#[clap(version = "1.0", long_about = None)]
Expand Down
35 changes: 34 additions & 1 deletion hugr-core/src/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ impl Package {
/// Validate the package against an extension registry.
///
/// `reg` is updated with any new extensions.
pub fn validate(&mut self, reg: &mut ExtensionRegistry) -> Result<(), PackageValidationError> {
pub fn update_validate(
&mut self,
reg: &mut ExtensionRegistry,
) -> Result<(), PackageValidationError> {
for ext in &self.extensions {
reg.register_updated_ref(ext)?;
}
Expand All @@ -104,6 +107,22 @@ impl Package {
Ok(())
}

/// Validate the package against an extension registry.
///
/// `reg` is updated with any new extensions.
///
/// Returns the validated modules.
///
/// deprecated: use [Package::update_validate] instead.
#[deprecated(since = "0.13.2", note = "Replaced by `Package::update_validate`")]
pub fn validate(
mut self,
reg: &mut ExtensionRegistry,
) -> Result<Vec<Hugr>, PackageValidationError> {
self.update_validate(reg)?;
Ok(self.modules)
}

/// Read a Package in json format from an io reader.
///
/// If the json encodes a single [Hugr] instead, it will be inserted in a new [Package].
Expand Down Expand Up @@ -258,6 +277,20 @@ pub enum PackageValidationError {
Extension(ExtensionRegistryError),
/// Error raised while validating the package hugrs.
Validation(ValidationError),
/// Error validating HUGR.
#[deprecated(
since = "0.13.2",
note = "Replaced by `PackageValidationError::Validation`"
)]
#[from(ignore)]
Validate(ValidationError),
/// Error registering extension.
#[deprecated(
since = "0.13.2",
note = "Replaced by `PackageValidationError::Extension`"
)]
#[from(ignore)]
ExtReg(ExtensionRegistryError),
}

#[cfg(test)]
Expand Down

0 comments on commit 678d6fc

Please sign in to comment.