diff --git a/pve-rs/Makefile b/pve-rs/Makefile index c912d9d..0b53d4d 100644 --- a/pve-rs/Makefile +++ b/pve-rs/Makefile @@ -20,6 +20,7 @@ PM_DIRS := \ PM_FILES := \ PVE/RS/APT/Repositories.pm \ + PVE/RS/CalendarEvent.pm \ PVE/RS/OpenId.pm \ PVE/RS/TFA.pm diff --git a/pve-rs/src/calendar_event.rs b/pve-rs/src/calendar_event.rs new file mode 100644 index 0000000..b898b15 --- /dev/null +++ b/pve-rs/src/calendar_event.rs @@ -0,0 +1,20 @@ +#[perlmod::package(name = "${PERLMOD_PRODUCT}::RS::CalendarEvent")] +mod export { + use anyhow::Error; + use perlmod::Value; + + perlmod::declare_magic!(Box : &CalendarEvent as "${PERLMOD_PRODUCT}::RS::CalendarEvent"); + + #[repr(transparent)] + struct CalendarEvent(proxmox_time::CalendarEvent); + + #[export(raw_return)] + fn new(#[raw] class: Value, event: String) -> Result { + Ok(perlmod::instantiate_magic!(&class, MAGIC => Box::new(CalendarEvent(event.parse()?)))) + } + + #[export] + fn compute_next_event(#[try_from_ref] this: &CalendarEvent, last: i64) -> Result, Error> { + this.0.compute_next_event(last) + } +} diff --git a/pve-rs/src/lib.rs b/pve-rs/src/lib.rs index 594a96f..2c25ee1 100644 --- a/pve-rs/src/lib.rs +++ b/pve-rs/src/lib.rs @@ -5,3 +5,4 @@ pub mod apt; pub mod openid; pub mod tfa; +pub mod calendar_event;