pve-rs: add PVE::RS::CalendarEvent

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-12-01 09:55:13 +01:00 committed by Thomas Lamprecht
parent 2f474e63f5
commit e75f545a2f
3 changed files with 22 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,20 @@
#[perlmod::package(name = "${PERLMOD_PRODUCT}::RS::CalendarEvent")]
mod export {
use anyhow::Error;
use perlmod::Value;
perlmod::declare_magic!(Box<CalendarEvent> : &CalendarEvent as "${PERLMOD_PRODUCT}::RS::CalendarEvent");
#[repr(transparent)]
struct CalendarEvent(proxmox_time::CalendarEvent);
#[export(raw_return)]
fn new(#[raw] class: Value, event: String) -> Result<Value, Error> {
Ok(perlmod::instantiate_magic!(&class, MAGIC => Box::new(CalendarEvent(event.parse()?))))
}
#[export]
fn compute_next_event(#[try_from_ref] this: &CalendarEvent, last: i64) -> Result<Option<i64>, Error> {
this.0.compute_next_event(last)
}
}

View File

@ -5,3 +5,4 @@ pub mod apt;
pub mod openid;
pub mod tfa;
pub mod calendar_event;