| Crates.io | patina_macro |
| lib.rs | patina_macro |
| version | 19.0.5 |
| created_at | 2025-10-12 03:38:06.612162+00 |
| updated_at | 2026-01-21 17:49:45.405592+00 |
| description | Proc-macro crate for the UEFI Software Development Kit (SDK). |
| homepage | |
| repository | https://github.com/OpenDevicePartnership/patina |
| max_upload_size | |
| id | 1878844 |
| size | 128,747 |
patina_macro hosts the procedural macros used in Patina. This includes those that support the Patina component
system, service registration, guided HOB parsing, on-target test discovery, and more. The
patina crate re-export these macros, so most cases only need a dependency on
patina.
#[component]entry_point method to define components.patina::component::IntoComponent.entry_point method must consume self and takes dependency-injected parameters implementing ComponentParam.ConfigMut<T> or mixing Config<T> and ConfigMut<T>.use patina::component::{component, params::Config};
struct BoardInit;
#[component]
impl BoardInit {
fn entry_point(self, config: Config<u32>) -> patina::error::Result<()> {
patina::log::info!("Selected profile: {}", *config);
Ok(())
}
}
#[derive(IntoService)]patina::component::service::IntoService for a concrete provider.#[service(dyn TraitA, dyn TraitB)].Note: The macro leaks the provider once and registers
'staticreferences so every component receives the same backing instance.
use patina::component::service::IntoService;
trait Uart {
fn write(&self, bytes: &[u8]) -> patina::error::Result<()>;
}
#[derive(IntoService)]
#[service(dyn Uart)]
struct SerialPort;
impl Uart for SerialPort {
fn write(&self, bytes: &[u8]) -> patina::error::Result<()> {
patina::log::info!("UART: {:?}", bytes);
Ok(())
}
}
#[derive(FromHob)]#[hob = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"].use patina::component::hob::FromHob;
#[derive(FromHob, zerocopy_derive::FromBytes)]
#[repr(C)]
#[hob = "8be4df61-93ca-11d2-aa0d-00e098032b8c"]
struct FirmwareVolumeHeader {
length: u32,
revision: u16,
}
#[patina_test]cfg_attr so they only compile when the runner is active.#[should_fail] or #[should_fail = "message"]#[skip]use patina::test::{patina_test, Result};
#[cfg_attr(target_arch = "x86_64", patina_test)]
fn spi_smoke_test() -> Result {
patina::u_assert!(spi::probe(), "SPI controller missing");
Ok(())
}
#[patina_test]
#[should_fail = "Expected watchdog trip"]
fn watchdog_negative_path() -> Result {
patina::u_assert_eq!(watchdog::arm(), Err("trip"));
Ok(())
}