mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Prepare pv & pv_core crates to be released on crates.io: * Remove any unused API to stay flexible * Remove utils dependency * Move cli, tmpfile and version utilities to local utils crate * Use the new utilities in the pv tools * Rename Secret into Confidential to avoid confusion of Secret (now Confidential) and AddSecret requests. * Move the uvsecret module out of the request module and change the name to secret. * Cleanup dependencies * Precise and correct minimal dependency versions * Inline `Aes256Key::from_digest` The cleanup ensures that the code also compiles with the dependencies resolved to their minimal versions using: $ cargo +nightly -Z minimal-versions update $ cargo build For more information refer to this blog post: https://users.rust-lang.org/t/psa-please-specify-precise-dependency-versions-in-cargo-toml/71277/8 Signed-off-by: Marc Hartmayer <mhartmay@de.ibm.com> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
63 lines
1.5 KiB
Rust
63 lines
1.5 KiB
Rust
// SPDX-License-Identifier: MIT
|
|
//
|
|
// Copyright IBM Corp. 2023, 2024
|
|
|
|
macro_rules! path_to_str {
|
|
($path: expr) => {
|
|
$path.as_ref().to_str().unwrap_or("no UTF-8 path")
|
|
};
|
|
}
|
|
pub(crate) use path_to_str;
|
|
|
|
macro_rules! file_error {
|
|
($ty: tt, $ctx: expr, $path:expr, $src: expr) => {
|
|
$crate::Error::FileIo {
|
|
ty: $crate::FileIoErrorType::$ty,
|
|
ctx: $ctx.to_string(),
|
|
path: $path.to_string(),
|
|
source: $src,
|
|
}
|
|
};
|
|
}
|
|
pub(crate) use file_error;
|
|
|
|
macro_rules! bail_spec {
|
|
($str: expr) => {
|
|
return Err($crate::Error::Specification($str.to_string()))
|
|
};
|
|
}
|
|
pub(crate) use bail_spec;
|
|
|
|
/// Asserts a constant expression evaluates to `true`.
|
|
///
|
|
/// If the expression is not evaluated to `true` the compilation will fail.
|
|
#[macro_export]
|
|
macro_rules! static_assert {
|
|
($condition:expr) => {
|
|
const _: () = core::assert!($condition);
|
|
};
|
|
}
|
|
|
|
/// Asserts that a type has a specific size.
|
|
///
|
|
/// Useful to validate structs that are passed to C code.
|
|
/// If the size has not the expected value the compilation will fail.
|
|
///
|
|
/// # Example
|
|
/// ```rust
|
|
/// # use pv_core::assert_size;
|
|
/// # fn main() {}
|
|
/// #[repr(C)]
|
|
/// struct c_struct {
|
|
/// v: u64,
|
|
/// }
|
|
/// assert_size!(c_struct, 8);
|
|
/// // assert_size!(c_struct, 7);//won't compile
|
|
/// ```
|
|
#[macro_export]
|
|
macro_rules! assert_size {
|
|
($t:ty, $sz:expr ) => {
|
|
$crate::static_assert!(::std::mem::size_of::<$t>() == $sz);
|
|
};
|
|
}
|