lib.rs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2006-2025, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author notes
  8. * 2025-10-25 foxglove Component registry for unified component registration
  9. * 2025-10-29 foxglove Updated to demonstrate new modular macro interface
  10. */
  11. #![no_std]
  12. extern crate alloc;
  13. /* Demonstrate the new modular macro interface */
  14. use rt_macros::rt_component_export;
  15. use rt_rust::param::{Param, ParamItem};
  16. use rt_rust::println;
  17. /* Re-export component functionality for other modules */
  18. #[cfg(feature = "enable-log")]
  19. pub use em_component_log::*;
  20. #[cfg(feature = "enable-log")]
  21. use em_component_log::logging::Level;
  22. /** Unified component registration entrypoint */
  23. #[cfg(feature = "enable-log")]
  24. #[rt_component_export(name = "rust_component_registry")]
  25. fn init_registry_component() {
  26. println!("[logging component init] hello world");
  27. log!(Level::Info, "hello world");
  28. info!("hello world");
  29. warn!("hello world");
  30. error!("hello world");
  31. trace!("hello world");
  32. debug!("hello world");
  33. }
  34. /** Provide a no-op implementation when no component feature is enabled */
  35. #[cfg(not(feature = "enable-log"))]
  36. pub extern "C" fn component_init() {
  37. /* Empty implementation to ensure the library still links */
  38. }