#redfish #macro #service #models #attributes #variant #define

过程宏 redfish-macros

Redfish服务实现中有用的宏

3个不稳定版本

0.3.1 2023年7月13日
0.1.1 2023年3月14日
0.1.0 2023年3月13日

#6 in #redfish

每月下载量 24次
4个crate中使用(通过redfish-codegen

MIT/Apache

12KB
204

redfish-macros

本crate提供了一些在Redfish服务实现中有用的过程宏。

目前,本仓库中只有宏 IntoRedfishMessage,它提供了以下实现:Into<redfish_codegen::models::message::<version>::Message>。这对于选择创建自己的注册表的Redfish实现者非常有帮助。它需要在enum上使用一个属性,并在每个变体上使用四个属性,如下所示

/// This registry defines the base messages for Redfish
#[derive(Clone, Debug, IntoRedfishMessage)]
#[message(crate::models::message::v1_1_2::Message)]
pub enum Base {
    /// This message shall be used to indicate that a property was not updated due to an internal service error, but the service is still functional.
    #[message(message = "The property %1 was not updated due to an internal service error.  The service is still operational.")]
    #[message(id = "Base.1.15.0.PropertyNotUpdated")]
    #[message(severity = "crate::models::resource::Health::Critical")]
    #[message(resolution = "Resubmit the request.  If the problem persists, check for additional messages and consider resetting the service.")]
    PropertyNotUpdated(
        /// This argument shall contain the name of the property.
        String,
    ),

    ...

然后可以执行以下操作

let base = Base::PropertyNotUpdated("a_property");
let message: Message = base.into();

依赖项

~3.5–4.5MB
~89K SLoC